Solved

String to Integer.

Posted on 2000-04-18
5
271 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

12 Experts available now in Live!

Get 1:1 Help Now