+ 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 ответов
+ 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!