Solved

String variable formats

Posted on 2004-08-21
1
142 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now