1错误代码
#include<stdio.h> int main(){ char a[]="hello"; char *p=a; for(int i=0;i<5;i++){ printf("%c",*p+i); } return 0; }
输出
hijkl -------------------------------- Process exited after 0.3297 seconds with return value 0
---
2正确代码(其中之一)
#include<stdio.h>
int main(){
char a[]="hello";
char *p=a;
for(int i=0;i<5;i++){
printf("%c",*(p+i));
}
return 0;
}
输出
hello -------------------------------- Process exited after 0.2415 seconds with return value 0
正确代码2
#include<stdio.h>
int main(){
char a[]="hello";
char *p=a;
printf("%s",p);
return 0;
}