A me continua a non compilare in nessun modo. Se uso questo codice
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
char* prova = itoa();
return 0;
}
char * itoa(int number){
char *str=(char *)malloc(sizeof(char)*20);
if(sprintf(str,"%d",number)<1){
exit(-1);
}
return str;
}
ottengo
main.c: In function ‘main’:
main.c:9:2: warning: implicit declaration of function ‘itoa’ [-Wimplicit-function-declaration]
main.c:9:16: warning: initialization makes pointer from integer without a cast [enabled by default]
main.c:9:8: warning: unused variable ‘prova’ [-Wunused-variable]
main.c: At top level:
main.c:13:8: error: conflicting types for ‘itoa’
main.c:9:16: note: previous implicit declaration of ‘itoa’ was here
Invece con
#include <stdio.h>
#include <stdlib.h>
char * itoa(int number);
int main(int argc, char const *argv[])
{
char* prova = itoa();
return 0;
}
char * itoa(int number){
char *str=(char *)malloc(sizeof(char)*20);
if(sprintf(str,"%d",number)<1){
exit(-1);
}
return str;
}
ho
main.c: In function ‘main’:
main.c:8:2: error: too few arguments to function ‘itoa’
main.c:4:8: note: declared here
main.c:8:8: warning: unused variable ‘prova’ [-Wunused-variable]
Non capisco come faccia Paolovox a compilare...