15 views
#include<stdio.h>
int fun(char *str1)
{
char *str2=str1;
while(*++str1)
return(str1-str2);
}
int main()
{
char *str="geeksquiz";
printf("%d",fun(str));
return 0;

}

this question is from geeksforgeeks.com in that the answer is ‘9’ but i compiled in gnu gcc compiler the answer is ‘1’

how?
| 15 views

If there is no semicolon after while loop then answer is $1$ and if there is a semicolon after while loop answer is $9$.