Is there are format function in C++? I need to line up a character array to the left and save to a variable.
e.g.
format("Hi", " @@@@@@@") = " Hi";
format("Bye"," @@@@@@@") = " Bye";
Thanks for any help :)
Printable View
Is there are format function in C++? I need to line up a character array to the left and save to a variable.
e.g.
format("Hi", " @@@@@@@") = " Hi";
format("Bye"," @@@@@@@") = " Bye";
Thanks for any help :)
There's no format function in C++, but theres a variety of string functions to deal with character arrays, you can for instance do it as follows:
here's documentation on the string functionsPHP Code:char* a= "Hi";
char c[10] = " ";
strcpy(c+10-strlen(a),a);
http://www.cplusplus.com/ref/cstring/index.html
Look at the format modules in the attached code
Thanks for your replies :)
Those work:8
If there is no format function, then what is sprintf? Only because it's C that doesn't mean it's bad.
Else look at stringstreams, they are very useful.
yes:
PHP Code:sprintf(str, "%-30s", "Hi"); // right align a string