字符串与指针
#include<stdio.h> #include<stdlib.h> int main(void) { char *p="abcdefg"; printf("%s\n",p); printf("%s\n","ABCD"); printf ("%s\n",p+4); printf ("%s\n","ABCD"+2); printf ("%c %c\n",p[3],*(p+1)); printf ("%c %c\n ","ABCD"[2],*("ABCD"+1)); system("pause"); return 0; }
1 #include<stdio.h> 2 #include<stdlib.h> 3 int main(void) 4 { 5 char *p="abcdefg"; 6 printf("%s\n",p 7 printf("%s\n","ABCD"); 8 printf ("%s\n",p+4); 9 printf ("%s\n","ABCD"+2); 10 printf ("%c %c\n",p[3],*(p+1)); 11 printf ("%c %c\n ","ABCD"[2],*("ABCD"+1)); 12 system("pause"); 13 return 0; 14 }
经常会弄错的,要多看看的。