Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 17506
  • Last Modified:

CString to int

How can I convert a data of CString type into int in EVC?
0
mwcmp
Asked:
mwcmp
1 Solution
 
millsoftCommented:

CString s;
int x;
x = atoi( (LPCTSTR) s );
0
 
jkrCommented:
You could use

#include <stdlib.h>

CString str = "42";
int i = atoi((LPCTSTR)str);
0
 
mwcmpAuthor Commented:
error C2664: 'atoi' : cannot convert parameter 1 from 'const unsigned short *' to 'const char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Kiran Paul VJComputer EngineerCommented:
0
 
mwcmpAuthor Commented:
but I am using a CString.
CString to int.
Not char to int.
0
 
AndyAinscowCommented:
The following works here

      CString s(_T("123"));
      int i = _ttoi(s);
i now has the value 123
0
 
mwcmpAuthor Commented:
thanks! :)
0
 
mwcmpAuthor Commented:
.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now