This should be simple, but pointers to char arrays still leave me scratching my head sometimes. gcc complains that "subscripted value is neither array nor pointer" in lines 4 and 5, and "invalid type argument of 'unary *'" on lines 8 and 11. Can someone explain what is going wrong here? I changed lines 4 and 5 to dereference the pointer first using brackets, but still can't get what I want.
This should be a pretty simple function:
1 void makesafestr ( const char *unsafe, const char *safe )
2 {
3 int offset=0;
4 for (; (*safe)[offset] != "\0" ; offset++) {
5 switch ((*unsafe)[offset]) {
6 case "\n":
7 case "\r":
8 *safe[offset] = "~";
9 break;
10 default:
11 *safe[offset] = *unsafe[offset];
12 }
13 offset++;
14 }
}