Change the string of the pointer
Given the character string definition char *a = "I love China!", read in the integer n, and output the character string corresponding to the character pointer a after the assignment of a = a + n.
Enter an integer n, and ensure that 0<=n<13.
Output the character string corresponding to a after the assignment operation in the title description.
Please pay attention to the line ending output.
enter
7
enter
China!
//改变指针的字符串
#include<iostream>
using namespace std;
int main(void)
{
int n;
cin>>n;
char *a = "I love China!";
char *p=(a+n);
while (*p)
{
putchar(*p); //单字符输出
p++;
}
return 0;
}