关于字符串数组问题

来源:百度知道 编辑:UC知道 时间:2024/06/18 09:49:04
我先在有N个字符串(N>1),想把它写进str[50]的字符串数组里,然后再把字符串显示出来。该怎么做啊?

#include <stdio.h>
void main()
{
char str[50][256];/* 每个字符串长度不能超过255 */
int i;
int count = 0;

/*输入*/
for(i=0;i<50;i++)
{
scanf("%s", str[i]);
if(str[i][0]=='\0') break;/*空串结束输入*/
count++;/*记录输入的字符串个数*/
}

/*输出*/
for(i=0;i<count;i++)
{
printf("%s\n", str[i]);
}
}

高手来拉