>I have used getline() but that didn't stop the compiler to get a value..
Post a full program that has the problem. I'm guessing that you have a cin>>[I]<blah>[/I] somewhere before the getline, and the getline is eating the leftover newline.
int n; // declare n of type integer
cout << " \n\n";
cout << " SET THE NUMBER OF EMPLOYEES" << endl;
cout << " --> ";
cin >> n;
// Loop until 'n' number of employees is reached //
// & Enter the data for each number of Employees //
// using the set functions //
for ( int i = 0 ; i < n ; i++ )
system("CLS"); // clear the screen
cout << "\n\n";
cout << " xxxxxxxxxxxxxxxx" << endl;
cout << " x EMPLOYEE # " << i+1 << " x" << endl;
cout << " xxxxxxxxxxxxxxxx" << "\n\n";
// Set the Name of the Employee
cout << " Enter the Name of Employee # " << i+1 << ": ";
getline ( cin, N );
myClass[i].setName( N );
Damn, I'm good. cin >> n; reads an integer, but leaves a newline on the stream. getline ( cin, N ); is supposed to stop reading when it finds a newline, so it looks like the call is getting skipped. There's a sticky thread about clearing the input stream that goes into a lot of detail about fixing the problem. But the best way to avoid it is not to use formatted input in the first place. Read everything as a string and use stringstreams (or boost::lexical_cast) to convert the string into the type you want.
Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...