Even with int foo(char str[]); which will take in an array initialized to a string literal sizeof doesn\'t work. I was asked to do something like strlen and the app
int foo(char str[]);
C strings are just arrays of char. Arrays are not passed by value in C; instead, a pointer to their first element is passed.
char
So these two are the same:
void foo(char blah[]) { ... } void foo(char *blah) { ... }
and these two are the same:
char str[] = "Hello"; foo(str); char *p = str; foo(p);