码迷,mamicode.com
首页 > 编程语言 > 详细

指针数组

时间:2016-06-14 14:19:56      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

 

 

#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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!