Re: [問題] 字串指標問題...

看板C_and_CPP (C/C++)作者 (嘿嘿...)時間16年前 (2009/12/31 22:24), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/4 (看更多)
給您參考一下~ 你應該就懂了.... #include <stdio.h> #include <stdlib.h> int main(void) { char *str="defg"; int value=3; int *ptr; ptr=&value; printf("%d\n",*ptr); printf("%s\n",str); //新增的部分 int i=0; while(*(str+i)!='\0') { printf("*(str+%d)=%c\n",i,*(str+i)); //*(str+0)等同*str i++; } // system("pause"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.229.203.98
文章代碼(AID): #1BFBG8pT (C_and_CPP)
文章代碼(AID): #1BFBG8pT (C_and_CPP)