error: `itoa` was not declared in this scope

itoa is not ansi C standard and you should probably avoid it. Here are some roll-your-own implementations if you really want to use it anyway:

http://www.strudel.org.uk/itoa/

If you need in memory string formatting, a better option is to use snprintf. Working from your example:

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

int main ()
{
  int i;
  char buffer [33];
  printf ("Enter a number: ");
  scanf ("%d",&i);
  snprintf(buffer, sizeof(buffer), "%d", i);
  printf ("decimal: %s\n",buffer);
  return 0;
}

Leave a Comment