Thread: string padding

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    44

    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.

  2. #2
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    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.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. string padding and replacement functions
    By George2 in forum Tech Board
    Replies: 4
    Last Post: 11-19-2006, 01:40 AM
  3. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 12:47 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM