_itoa_s undeclared identifier

Started by
5 comments, last by Kai001 16 years, 4 months ago
I'm getting the error "error C2065: '_itoa_s' : undeclared identifier" even though I've included stdlib.h The function: _itoa_s(ammo, strAmmoText, 10); Any help is greatly appreciated!
Advertisement
Did you use angled brackets when you included the file? I.e. #include <stdlib.h>, or quote marks? (Angled brackets are correct).

Also, are you using VC2005 or VC2008? The function probably doesn't exist in other compilers.
_itoa_s() is a non-standard function. It could be that your compiler doesn't support it.
I'm using VC 6.0.

I thought that maybe I should convert the int another way by adding:
#include <sstream>

std::stringstream ss;
std::string str;

...

static char strAmmoText[10];
ss << ammo;
ss >> strAmmoText;
dxfont->DrawTextA(NULL,
(LPCSTR)&strAmmoText,
strlen((LPCSTR) &strAmmoText),
&Part,
DT_RIGHT,
D3DCOLOR_ARGB(255, 120, 120, 255));

Now when I run it it displays no text.
Once again, I shall suggest use of the wonderful boost::lexical_cast .

std::string strAmmoText = boost::lexical_cast<string, int>(ammo);
Quote:Original post by Kai001
I'm using VC 6.0.

Stop. Go download MSVC 2008 Express and use that. MSVC 6.0 has a broken and pre-standard compiler, not to mention that it's horribly outdated. 2008 is superior in every way.

By the way, ss >> strAmmoText; is a bad idea. (You're telling the stringstream to output to a char *, which does not make a lot of sense, as it has no idea how large the buffer is.) Just do std::string str = ss.str();, then pass in str.c_str() and str.length() to the function you're calling.
Ra
MJP, I tried the lexical_cast but I can't find all the header files it wants.. All I can find is lexical_cast.hpp and not config.hpp.

Ra, I just tried the new VC++2008 and it came up with 18 errors in my source and in atlbase.h, which is nessicary for my project and was written my Microsoft not me.

Thanks for the help so far. :D

This topic is closed to new replies.

Advertisement