Need help with String and .format (or good links to help)

This is a discussion on Need help with String and .format (or good links to help) within the C++ Programming forums, part of the General Programming Boards category; Hello cboard, Im an engineering student working to another students old program, and their are some confusing bits of code ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    3

    Need help with String and .format (or good links to help)

    Hello cboard,

    Im an engineering student working to another students old program, and their are some confusing bits of code i would like cleared up. If somebody already has I apologize

    For example he has a

    Cstring= s_progress;

    and he uses it like so:

    s_progress.Format("(Some Text used in program here) +%.4f inches toward (rest of text here)", (somepreviouslydelcared_variable);

    My first question is:
    what the heck does %.4 mean? obviously it refers to the variable, but i am not so clear.

    And my second is: Is there a list of member functions like .Format and .getline() that list the functions and their uses? This would be very helpful me and others.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    CString is an MFC class, so you can look in MSDN for information about how to use it. Note that Format is a CString member function, but getline is not. MSDN should also have information about standard C++ functions like getline if you want to use a single reference for both microsoft specific stuff (like CString) and standard C++ stuff like getline.

    To find out what %.4f means, you can look up CString::Format, which will point you to printf style format specifiers. Basically, it indicates that the somepreviouslydelcared_variable value should be placed inside the string where the %.4f is, and the ., 4, and f all give information on how that value is formatted in the string.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    3

    thx

    thx for the quick response....i tried looking it up on M$ but i got confused...ill try harder....

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    MSDN is difficult to search through. Some people prefer to use site:msdn.microsoft.com in their google search (although msdn2.microsoft.com might be better) because google does a better job than the built in MSDN search. When you find results, just make sure you are looking at Visual C++ and not Visual Basic, CLR, C++/CLI, .NET, etc.

  5. #5
    Registered User
    Join Date
    Dec 2006
    Posts
    3

    thx

    thx for the tips...

    and its a shame that google searches M$ better than M$

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21