If the declaration of argument matches the declaration of the formal parameter, then the argument is passed by value.
It's pass by value. You are passing the value of the pointer a. So you get 'abc' instead of 'bc'. If you want to get 'bc', use: void f (char * &a)void f (char * a)
{
a++;
}
int main (void)
{
char *a = "abc";
f(a);
puts (a);
return 0;
}
No comments:
Post a Comment