[LC++]IO in C++
Mark Phillips
mark at austrics.com.au
Thu Nov 1 15:09:13 UTC 2001
Hi,
Suppose I have an integer and I wish to convert it to a
string. I can do:
int myInt=259;
char myCstr[20];
sprintf(myCstr, "%d", myInt);
Or suppose I have a string and I wish to convert it to an
int. I can do:
int myInt;
string myString="259";
istringstream iss(myString);
iss>>myInt;
But both of these seem a bit inelegant. Are there better
ways of doing this kind of thing.
The other thing is, I have heard it said that cout is bad for
doing output formatting, and that printf should be used, even
in C++. Do people agree?
What alternatives are there for dealing with IO in C++? There
seems to be no sensible and flexible framework. Am I wrong?
Thanks,
Mark.
More information about the tuxCPProgramming
mailing list