Kirk Garvey wrote:
Hi,
As an experienced 'C' programmer but C++ novice I am wondering what is the best programming practice for standard input/output when programming C++, should one use 'printf()' and 'sprintf()' or 'cout' and 'cin'? Or is it down to personal preference?
Personally I use both. When I just want to simply print unformatted data I use cout but if I have much formating, especially if part of a line is formated significantly different than another part I find printf much easier. Along the same lines I have found that for reading data that has a complex format that scanf is easier than cin. I have also noticed that some C programmers aren't even aware of the power of the scanf and printf. I'm not as expert with cin and cout as I am with printf and scanf but one time I wrote code to read in a data file in both C and C++ and found that the scanf did it in one scan statement where with cin I had to read the whole line into a buffer and do significant processing to store the values. If anyone is interested I can post the code and they can show me how it could be done easier in C++ -- Chris W Not getting the gifts you want? The Wish Zone can help. http://thewishzone.com