1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
cout << "Do you wish to create another packet? (Y/N)\n: ";
cin >> another_packet;
while (true)
{
if(make_another_packet(another_packet)==1)
{
break;
}
else
{
create_packet(temp_packet, packet[nPackets] /*ptr_nPackets*/ ); //error
break;
}
}
//........................ //skip to create_packet, I presume the error is at the bottom of this
void create_packet(temp_CPacket temp, CPacket packet[] /*int* ptr_nPackets*/ )
{
cout << "\nSource Address (1-1024): ";
cin.ignore(255,'\n');
getline(cin, temp.buffer);
temp.src = validate_string(temp.buffer, temp.src);
while((temp.src > 1024 || temp.src < 1))
{
cout << "\nInvalid data entry, please re-enter: ";
getline(cin, temp.buffer);
temp.src = validate_string(temp.buffer, temp.src);
}
cout << "\nDestination Address (1-1024): ";
getline(cin, temp.buffer);
cin.ignore(255,'\n');
temp.dst = validate_string(temp.buffer, temp.dst);
while((temp.dst > 1024 || temp.dst < 1))
{
cout << "\nInvalid data entry, please re-enter: ";
getline(cin, temp.buffer);
temp.dst = validate_string(temp.buffer, temp.dst);
}
cout << "\nType (0-10): ";
getline(cin, temp.buffer);
cin.ignore(255,'\n');
temp.typ = validate_string(temp.buffer, temp.typ);
while((temp.typ > 10 || temp.typ < 0))
{
cout << "\nInvalid data entry, please re-enter: ";
getline(cin, temp.buffer);
temp.typ = validate_string(temp.buffer, temp.typ);
}
cout << "\nPort (1-1024): ";
getline(cin, temp.buffer);
cin.ignore(255,'\n');
temp.prt = validate_string(temp.buffer, temp.prt);
while((temp.prt > 1024 || temp.prt < 1))
{
cout << "\nInvalid data entry, please re-enter: ";
getline(cin, temp.buffer);
temp.prt = validate_string(temp.buffer, temp.prt);
}
cout << "\nData (50 chars max): ";
getline(cin, temp.dat);
while (validate_dataString(temp.dat)==false)
{
cout << "\nInvalid data entry, please re-enter: ";
getline(cin, temp.dat);
cin.ignore(255,'\n');
}
cout << "\nPacket " << nPackets << " created.";
nPackets++;
packet[nPackets].set_values(temp); //possibly the location of error?
}
|