+ 1
String
#include <stdio.h> #include <stdlib.h> #include <string.h> void a(char**strref){ ++strref; } int main() { char *s="hour"; a(&s); puts(s); return 0; } I think the result of the code is âourâ,but not. Who can tell me why? đč
3 Answers
+ 4
You need to change ++strref; to ++*strref;
This is because without the * then itâs just changing the value of strref inside the a function, not inside the main function.
P.S. Next time, please put the programming language as a tag!
+ 4
No worries!
+ 1
Thanks, Rowsej!