How to change CString to a 64 bit integer

Posted on 2006-03-24
Last Modified: 2008-03-06
Hi Experts,

How can I change a CString to 64 bit integer?  
Question by:thanesh
    LVL 12

    Expert Comment

    CString str("2342353465664");

    LVL 12

    Accepted Solution

    Error free code.
    CString str("2342546546754756786678");
    __int64 data = _atoi64((LPCTSTR)str);
    LVL 1

    Author Comment

    Hi Rajeev,

    Thanks. Why would the first one be error prone?
    LVL 12

    Expert Comment

    Two reasons

    1. GetBuffer(int nMinBufLength );  takes one parameter.

    2. You need to store the converted value somewhere :)
    __int64 data =

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

    734 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

    25 Experts available now in Live!

    Get 1:1 Help Now