Problem with C function of type char pointer, can someone explain?
Posted
by JJ
on Stack Overflow
See other posts from Stack Overflow
or by JJ
Published on 2010-04-07T13:44:15Z
Indexed on
2010/04/07
13:53 UTC
Read the original article
Hit count: 197
Filed under:
c
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.
© Stack Overflow or respective owner