-
printf
i just came across the functions printf () and scanf ()...i didn't know what they were so i looked at them...after a bit i started really liking them compared to cout and cin.. is there a problem with me using those functions instead of cout and cin? (or a few other C functions as opposed to the ones in C++)?
is it a bad thing? i thought that if i liked using these better then why not..
anyways i just want to know what the experts have to tell me.. :)
thanks in advance
Amon Ra
-
Not a bad thing, but using printf() as opposed to cout might make the final .exe smaller :)
-
ok, so i think i will stick with them.. :)
thanks
Amon Ra
-
they do not have as much features as cout :(
-
You should use cout/cin in C++ programs, since printf and scanf are laughably non-type-safe.
And also, you can't overload the % flags in printf to output your own objects, but you can in C++:
Code:
cout << myobject << endl;
Trust me, use the streams.
-
i like printf and scanf better because they're easier to use
PHP Code:
printf("you entered %s and %s\n", string1, string);
cout<<"you entered "<<string1<<" and "<<string2<<endl;
scanf("%[a-z]", &cLetter);
//im not sure how to input only letters using the streams
-
Another thing, like parksie said, is cout is "type-safe", meaning you can basically print any variable without having to know its type (no %s, %d, etc.) or overload the << operator for your own classes.