-
string padding
I'm getting this error
Game.cpp:645: warning: cannot pass objects of non-POD type ‘struct std::string’ through ‘...’; call will abort at runtime
Game.cpp:645: warning: format ‘%*s’ expects type ‘char*’, but argument 3 has type ‘int’
with this code:
Code:
string boardTimeholder=boardTime->toString();
printf("%*s",8,boardTimeholder);
And my toString returns a string. I'm really confused.
-
Use %s to print out a c-string (char*). If you want to print an std::string, either use iostream or you can get the c string equivalent with the c_str() method of string.