What is the output? (Explain) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the output? (Explain)

/* Can someone give me a better solution and explain me how to get the output for this source code? */ #include <stdio.h> #include <string.h> char *f(int p, char *s) { s[p+2] = '\0'; return s-1; } int main(void) { char s[] = "ABCDEF"; int i = strlen(f(1, s+2)); printf("%d\n", i); return 0; }

6th Apr 2020, 8:13 AM
Isuru Harischandra
Isuru Harischandra - avatar
1 Answer
+ 1
Go into the Code section of SoloLearn, press the "+" icon to add new code, select C language, then enter your code and run. There you can see the output and experiment to understand it better.
6th Apr 2020, 5:17 PM
Brian
Brian - avatar