Using write() with integers in C

I'm trying to write an integer to a file using the write() function, but write() requires the parameter to be written to be a const void*.

How would I go about doing this?

also: using itoa() produces a " warning: implicit declaration of function 'itoa' " even though i have #included stdlib.h

int i=13;
write(my_fd, &i, sizeof(i));

This stores the internal integer the way it is stored in memory inside the file.
To make it human readable, assuming 32 bit integers:

char tmp[12]={0x0};
int i=13;
sprintf(tmp,"%11d", i);
write(my_fd, tmp, sizeof(tmp));

This writes a nul terminated string to the disk.

This is because itoa is not an ANSI C function (though its converse function, atoi, does) so its prototype is not in the stdlib.h header file as you would expect. Probably it is even not supported by your environment. jim mcnamara showed us the portable way one can format an integer into a string using the ANSI sprintf function (check also its secure version, snprintf).