248 views
1 votes
1 votes
Int fun( char *str1)

{

char *str2=str1;

while(* ++str1); || here it accesses the data then increments or increments and then checks the data?

return(str1-str2);

}

main()

{

char * str = "Ravindran";

printf("%d",fun(str));

}

a)10

b)9

c)8

d)random number

1 Answer

2 votes
2 votes
In while(*++str); see both ++ and * is having the same precedence but assosciativity is from RIGHT to LEFT so first it will increment and then check the data and loop will terminate when it will find NULL.

No related questions found