which is better to use?
If your trying to adhere to standard C++, the choice is obvious.
printf is still covered by the C++ standard. I like streams type safety (never forget the formatter) and extensibility (can use directly with own classes), but printf has more terse sematics (for example, limiting number of decimal places with output).
Wow, I didn't know that. Ya see you learn something new here everyday.printf is still covered by the C++ standard.
Why do you often hear people say that using printf is a mix of C and C++ and should not be done? Because I have had several people here tell me that.
I agree 100% with silent strike.
I don't know where I'd by without the c string functions (ie: strcat, strtok, strcpy, etc.)
I use c functions all the time right beside C++, i think people who strictly adhere to one or the other are severly limiting themselves in the power and versatility of their programs, as well as their creativity.
PHP and XML
Let's talk about SAX
adhering to c++ allows (read: forces) you to use c++'s object-oriented features. it can help where c might bog you down to its lowest denominator. ie:
the first three statements are somewhat encapsulated. the details are somewhat hidden. when you reach printf, which knows nothing about classes, you must use a special function of the string class to maintain compatability.Code:string temp; temp = "string"; cout << string << setw(5) << string << endl; printf("%s\n",string.c_str());
i'm not against using both at once. c++ was built for backwards-compatability. i just believe that object-oriented programming works best when the objects interact without the C functions that are unaware of classes.
yes but i here that you should try to use c++ functions and were you need to do somethign like strlen, use it.
Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: firstname.lastname@example.org
-the shroom has spoken
>which is better to use?
My rule of thumb is to use the iostream with C++ and the stdio with C.
My best code is written with the delete key.
Just don't use both. It can lead to some weird problems.