Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Convert long long to string

Posted on 2007-07-25
3
Medium Priority
?
691 Views
Last Modified: 2013-12-14
How can I convert a long long to a string.
0
Comment
Question by:ITSpgrmr
3 Comments
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 2000 total points
ID: 19569761

Lots of ways.  :)

  char Buffer[100];
  long long i;

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


or

  String  X;
  long long i;

  X = (String) "" + i;


Kent
0
 
LVL 86

Expert Comment

by:jkr
ID: 19569825
>>  sprintf (Buffer, "%I64d", i);

That uses a '__int64' format argument...

>>  String  X;

...is not a C++ standard data type.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 19572407
>> >>  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).
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

580 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