标签:
#include <stdio.h> const size_t BU=512; char buffer[512]; char *pS[3]={NULL}; char *pbuffer =buffer; size_t index =0; int main (void) { int i; printf("\nEnter 3 messages that total less than %u characters",BU-2); for (i=0;i<3;i++) { printf("\nEnter %s message \n",i>0?"anther":"a"); pS[i]=&buffer[index]; for (index=0;index<BU;index++) if(*(pbuffer+index)=getchar()==‘\n‘) { *(pbuffer+index++)=‘\0‘; break;//接受下一句话 } if((index==BU)&&(*(pbuffer+index-1)!=‘\0‘)) { printf("\n You ran out of space in the buffer"); return 1; } } printf("\n The.........are:\n"); for (i=0;i<3;i++) printf("%s\n",*(pS[i])); printf("\n%d,used\n",BU-index); system("pause"); return 0; }
为啥老是输出空指针,
http://blog.csdn.net/phunxm/article/details/5081159
标签:
原文地址:http://www.cnblogs.com/xinqidian/p/5583662.html