i want to convert long integer to string

S

seema

I am working under a Linux environment, and I want to convert a
long int into a string. It looks doesnt't have a function such ltoa,itoa
on stdlib.
How Can I do that?
I tried to work with double numbers, and convert them using fcvt
function included into stdlib, but after compiled, when I run the
job, I got an error:
Segmentation Error (core dumped).
I don't know what to do!
seema
 
C

Christian Staudenmayer

seema said:
I am working under a Linux environment, and I want to convert a
long int into a string. It looks doesnt't have a function such ltoa,itoa
on stdlib.
How Can I do that?
I tried to work with double numbers, and convert them using fcvt
function included into stdlib, but after compiled, when I run the
job, I got an error:
Segmentation Error (core dumped).
I don't know what to do!
seema

char tmp[255];
long foo;

sprintf(tmp, "%d", foo);

See the printf manpage for appropriate conversion rules.

Greetings, Chris
 
C

Christian Staudenmayer

Christian Staudenmayer said:
seema said:
I am working under a Linux environment, and I want to convert a
long int into a string. It looks doesnt't have a function such ltoa,itoa
on stdlib.
How Can I do that?

char tmp[255];
long foo;

sprintf(tmp, "%d", foo);


I guess you meant to write

sprintf(tmp, "%ld", foo);
Regards, Jens

Oops.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top