Solved

String to Integer.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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