Hey, my problem is as follows:
when I pass a variable into array[a] from c I lose the first word.
my code:
can anyone help?Code:#include <iostream> #include <cstring> using namespace std; int main() { char b; int a; char c[256]; string array[100]; top: cout<< "Enter choice, (w)rite / (r)ead / e(x)it: "; cin>> b; if ( b == 'w' ) { goto write; }else if ( b == 'r' ){ goto read; } else if ( b == 'x' ){ goto ntop; } else { cout<<"Bad Input!" <<"\n"; goto top; } write: cout << "Enter slot: "; cin >> a; cout << "Enter data: "; cin >> c; cin.getline (c, 256); array[a] = c; if (c == array[a]){ cout<<"Success! \n"; } else { cout<<"Failure! \n"; } goto top; read: cout << "Enter slot to read: "; cin >> a; cout << "Data in slot " <<a << ":\n" << array[a] <<"\n"; goto top; ntop: cout << "Exiting...goodbye"; cin.ignore(); cin.get(); return 0; }
thanks...