Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

String variable formats

Posted on 2004-08-21
1
Medium Priority
?
156 Views
Last Modified: 2013-11-20
In the following lines of code:

m_strFreeMemory.Format("%ld KB");
m_strMemoryLoad.Format("%d %%");

What does %d, %%, %ld do exactly?
0
Comment
Question by:fattumsdad
1 Comment
 
LVL 5

Accepted Solution

by:
Nass89 earned 200 total points
ID: 11862348
Hi,
The correct codes are:
m_strFreeMemory.Format("%ld KB", a);
m_strMemoryLoad.Format("%d",a);
it must contain an arguemnt for every '%' you use.

"%ld KB", is the format specifier and a is the arguement. The first part specifies which format to use to store the arguement in string.
example:
int a=255;
m_strFreeMemory.Format("%d ", a); --------> Display: 255
m_strFreeMemory.Format("%x ", a); --------> Display: 0xff
m_strFreeMemory.Format("%X ", a); --------> Display: 0xFF


A format specification has the following form:

%[-][#][0][width][.precision]type

See 'wsprintf' in MSDN for more info.

Good Luck!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question