Possible Duplicate:
Is array name a pointer in C?
Array Type - Rules for assignment/use as function parameter
This is the code that i wrote for an exercise in K&R C. The task is pretty simple, to replace '\t' with \ and t and not the tab character
the following is the code
char* escape(char s[], char t[]){
int i = 0, j = 0;
for(i = 0; t[i] != '\0'; i++){
switch(t[i]){
case '\t':{
s[j++] = '\\';
s[j++] = 't';
break;
}
default:{
s[j++] = t[i];
break;
}
}
}
s[j] = t[i];
return s;
}
int main(){
char t[10] = "what \t is";
char s[50];
s = escape(s,t);
printf("%s",s);
return 0;
}
It returns an error saying inappropriate type assignment betweenn char[50] and char* but isn't the name of the array supposed to be the pointer to the first element?