'itoa': The POSIX name for this item is deprecated

Dan Murphy picture Dan Murphy · Oct 24, 2017 · Viewed 15.8k times · Source

I'm trying to convert an int into a string by doing this:

int id = 12689;
char snum[MAX];
itoa(id, snum, 10);

I get the following error:

'itoa': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _itoa.

Answer

Weather Vane picture Weather Vane · Oct 24, 2017

That is MSVC doing that to you. If you add the following line before any library #includes

#define _CRT_NONSTDC_NO_DEPRECATE

the warning is suppressed, similar for many other functions too.

Moreover if you add these two lines as well, MSVC will stop telling you to use scanf_s instead of the standard function scanf (and others).

#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE