A
adamrobillard
Hi,
I went through most of the FAQ but did not find any direct references
formatting outputed data. If I have a application in C like so:
void main(void)
{
int nValue = 100;
double dPi = 3.14159265;
char sName[256] = {"Morpheus"};
printf("Name: %10s, Value: %4d, Pi: %0.2f", sName, nValue, dPi);
getchar();
}
How would I format the output using cout and string variables. Is it
valid to use sprintf to format your output then use cout to display it?
If so, how can you sprintf into a string?
I have read up on .precision etc but after several lines of code I
still do not end up with the results I am looking for. Is there a one
line solution like in C?
Thanks,
I went through most of the FAQ but did not find any direct references
formatting outputed data. If I have a application in C like so:
void main(void)
{
int nValue = 100;
double dPi = 3.14159265;
char sName[256] = {"Morpheus"};
printf("Name: %10s, Value: %4d, Pi: %0.2f", sName, nValue, dPi);
getchar();
}
How would I format the output using cout and string variables. Is it
valid to use sprintf to format your output then use cout to display it?
If so, how can you sprintf into a string?
I have read up on .precision etc but after several lines of code I
still do not end up with the results I am looking for. Is there a one
line solution like in C?
Thanks,