Problem with C function of type char pointer, can someone explain?
- by JJ
Find the errors from following C function :
char* f(int i) {
int i;
char buffer[20];
switch ( i ) {
1: strcpy( buffer, "string1");
2: strcpy( buffer, "string2");
3: strcpy( buffer, "string3");
default:
strcpy(buffer, "defaultstring");
}
return buffer;
}
this is c funtion not C++, I think it has to do with type conversion
my compiler give warning that declaration of int i shadows a parameter.