Solved

String variable formats

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best tools for Backup and restore of Wordpress site 6 58
MaxSpan challenge 9 122
scoreUp challenge 14 68
Windows shortcut location resolution on double click open 4 47
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

679 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