Solved

String variable formats

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 78
Host to IP 7 73
iSeries DB2 Query 2 84
maxBlock challenge 30 100
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

17 Experts available now in Live!

Get 1:1 Help Now