Solved

String to Integer.

Posted on 2000-04-18
5
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 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