Returning char* in function
- by Devel
I have function:
char *zap(char *ar) {
char pie[100] = "INSERT INTO test (nazwa, liczba) VALUES ('nowy wpis', '";
char dru[] = "' )";
strcat(pie, ar);
strcat(pie, dru);
return pie;
}
and in main there is:
printf("%s", zap( argv[1] ) );
When compiling I get the warning:
test.c: In function ‘zap’:
test.c:17: warning: function returns address of local variable
How should I return char* propertly?