Re: [問題] 字串指標問題...
給您參考一下~ 你應該就懂了....
#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
討論串 (同標題文章)
完整討論串 (本文為第 4 之 4 篇):
5
12
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章