In the following code why does the getline statement get skipped in the first iteration.
Now if I add "getline(cin,names[0],'\n');" just before the loop the problem is solved.Code:vector<string> names(r); for(i=0;i<r;i++) { getline(cin,names[i],'\n'); cout<<i<<endl; fflush(stdin);//does not help fflush(stdout);//does not help }
what do you think is the problem and is there a an alternative to the workaround I came up with.
Also what is the best way to input a string into an 1)array of chars(other than gets)
2)stl string (multiple words)
Hope someone figures this out.
Cheers!