It is very easy to convert any variable into a different kind in many languages, which gave me an idea for another converting function, which should act like str() from Python.
So what I found out is that itoa() is a function that turns an int to a char * (string):
#include <stdio.h> #include <stdlib.h> int main() { int num = 200; printf("%s", itoa(num)); } But as it turns out, itoa() doesn't actually exist in my version of C, which they claim is C99:
make_str.c:6:18: error: implicit declaration of function 'itoa' is invalid in C99 [-Werror,-Wimplicit-function-declaration] printf("%s", itoa(num)); ^ make_str.c:6:18: error: format specifies type 'char *' but the argument has type 'int' [-Werror,-Wformat] printf("%s", itoa(num)); ~~ ^~~~~~~~~ %d So I went to make my function instead called make_str(), though I still don't have a plan about how to convert variables into strings:
char *make_str(void *var) { } Q: What other functions can I use to change the variables into strings?
No, not floating-point values, only
int.
sprintf()?sprintf(), andsnprintf()since C99, come to minditoa()is not described by any version of the C Standard, or even POSIX.sprintfandsnprintf, you are wrong. Check the difference betweenprintf(orfprintf) andsprintf.printf()-family needs too much RAM or ROM.