Solved

String to Integer.

Posted on 2000-04-18
5
273 Views
Last Modified: 2013-11-20
hi,
 I am reading an integer from a file by a CString variable. I want to pass this parameter to a routine which accepts integer.
So how do I convert the read string (which is a read as string) to integer ?
0
Comment
Question by:mkjoshi
5 Comments
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2725824
Hi Joshi
Use CString::Format().

Example:
long lNum = 111;
CString strString;

strString.Format("%d", lNum);

Vicky
0
 

Accepted Solution

by:
Meybe earned 50 total points
ID: 2725834
it is very simple:)
simply use the atoi() function. and it will work fine:)

example:
CString str("10");
int i = atoi(str);

// now call your function
YourFunction (i);

Regards
0
 

Expert Comment

by:atti75
ID: 2725841

Hy!

Vicky> mkjoshi wants the reverse operation... int from string

 use this:
CString str = "1234";
int i;

i = atoi(LPCTSTR(str));

you can see MSDN for more help...
Good Luck!

0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2725848
atti75: You are right.

Sorry guys.

Yes. atoi() is the answer.
0
 

Author Comment

by:mkjoshi
ID: 2725957
THANKS A  LOT!,
     You made my work simple....
Have a nice time with VC++
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 50
Expand data scrubbing tool 13 32
Detect CR LF to each line 12 161
Message not shown 5 50
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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 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