Convert long long to string

Posted on 2007-07-25
Last Modified: 2013-12-14
How can I convert a long long to a string.
Question by:ITSpgrmr
    LVL 45

    Accepted Solution


    Lots of ways.  :)

      char Buffer[100];
      long long i;

      sprintf (Buffer, "%I64d", i);


      String  X;
      long long i;

      X = (String) "" + i;

    LVL 86

    Expert Comment

    >>  sprintf (Buffer, "%I64d", i);

    That uses a '__int64' format argument...

    >>  String  X; not a C++ standard data type.
    LVL 53

    Expert Comment

    >> >>  sprintf (Buffer, "%I64d", i);
    >> That uses a '__int64' format argument...

    The C99 standard prescribes to use %ll (and the variants %lld, %lli, %llo, %llu, %llx, %llX, %lln), but not all compilers support that yet. Some use %q (BSD eg.) or %L (although that often means long double), and Microsoft's compiler uses %I64d (for __int64).

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Article by: SunnyDark
    This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
    Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    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.

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now