How to convert an integer into a string

  • Thread starter silverburgh.meryl
  • Start date
S

silverburgh.meryl

In my c++ code, I try to call "itoa"

#include <stdio.h>
#include <stdlib.h>

int index2
char buffer [4];
::itoa (index2,buffer,10);

but I get this compile error:

Context.cpp:2304: error: '::itoa' has not been declared

Can you please tell me how to fix that?

Thank you.
 
S

silverburgh.meryl

I would like to do this on Linux, with G++. I think this question is
on-topic in this newsgroup.

Thanks for any help.
 
G

Geo

I would like to do this on Linux, with G++. I think this question is
on-topic in this newsgroup.

Thanks for any help.

int i = 1234;
std::stringstream ss;
ss << i;
std::string str(ss.str());
 
M

Marcelo Pinto

(e-mail address removed) escreveu:
i think its "_itoa()", isn't it?

According to the Standard (17.4.3.1.2):

"Each name that begins with an underscore is reserved to the
implementation for use as a name in the global namespace."

Thus this name (_itoa) is reserved to the implementation and as such is
implementation specific, and off-topic.

HTH,

Marcelo Pinto.
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top