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
Solved

CString to int

Posted on 2004-08-10
8
17,495 Views
Last Modified: 2013-11-20
How can I convert a data of CString type into int in EVC?
0
Comment
Question by:mwcmp
8 Comments
 
LVL 5

Expert Comment

by:millsoft
ID: 11766642

CString s;
int x;
x = atoi( (LPCTSTR) s );
0
 
LVL 86

Expert Comment

by:jkr
ID: 11766653
You could use

#include <stdlib.h>

CString str = "42";
int i = atoi((LPCTSTR)str);
0
 

Author Comment

by:mwcmp
ID: 11769514
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 16

Expert Comment

by:kiranvj
ID: 11769573
0
 

Author Comment

by:mwcmp
ID: 11769670
but I am using a CString.
CString to int.
Not char to int.
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 100 total points
ID: 11770455
The following works here

      CString s(_T("123"));
      int i = _ttoi(s);
i now has the value 123
0
 

Author Comment

by:mwcmp
ID: 11776093
thanks! :)
0
 

Author Comment

by:mwcmp
ID: 11807657
.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 94
List out all word 7 317
wait notify demo infinite loop 3 124
Fibonacci challenge 11 133
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

829 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