Solved

CString to int

Posted on 2004-08-10
8
17,485 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
 
LVL 16

Expert Comment

by:kiranvj
ID: 11769573
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

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

Title # Comments Views Activity
bobThere java chalenge 45 85
maxBlock challenge 30 101
sum28 challenge 31 96
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 92
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

13 Experts available now in Live!

Get 1:1 Help Now