What is the output of the following C program?
[gamipress_button type=”submit” label=”Run Code Online” onclick=”window.open(‘https://coderseditor.com’,’_blank’)”]
int fun(char *str1) { char *str2 = str1; while(*++str1); return (str1-str2); } int main() { char *str = "geeksforgeeks"; printf("%d", fun(str)); getchar(); return 0; }
Studently Answered question October 10, 2022
Output: 13
The pointer str2 is initialised as str1 and moved until it reaches ‘0’ inside of the fun() function (note ; after while loop). Therefore, str1 will be raised by 13.
Studently Answered question October 10, 2022