current position:Home>Char function and string program running

Char function and string program running

2022-02-03 01:42:20 CSDN Q & A

Why is the result of the following procedure love China! instead of I love China! Well
include<stdio.h>
main()
{ char *s2="I love China!";
s2=s2+2;
printf("%s\n",s2);
}




Refer to the answer 1:

s2 Originally, it points to the first address of the string
s2 = s2+2 It means moving back two places
Yes love Of l




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030142188314.html

Random recommended