What are the differences between cout << and printf() ?
Is there any advantage to using one over the other?
Also, cin >> has a method called .getline that allows you to convert white spaces without terminating by declaring a string array.
Example:
#include <iostream.h>
#include <string.h>
void main()
{
string szName[50];
cin.getline( szName, 50, '\n' )
cout << szName << endl;
}
Returns up to 50 characters including white spaces
Is there any way to keep the scanf() function from terminating on a white space? or must you assign each string of user input to a seperate variable?
I know there are some formatting options you can set following the % sign (type being madantory) including width and some others, but I can't seem to find the equivelent of cin.getline.
Sorry this post is turning out longer than I expected, but if anyone cares to discuss exception handling for either of these functions I'm also interested in learning some methods to keep users from entering incorrect values ... i.e. letters where an integer is expected or exceeding the max string array.
Thanks in advance.



LinkBack URL
About LinkBacks


