首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

C primer中的一个程序,求授予解答

2012-08-03 
C primer中的一个程序,求给予解答#includestdio.h#includestring.h#define SIZE 40#define LIM 5int m

C primer中的一个程序,求给予解答
#include<stdio.h>
#include<string.h>
#define SIZE 40
#define LIM 5
int main()
{

char qwords[LIM][SIZE];
char temp[SIZE];
int i=0;

printf("Enter %d words beginning with q:\n",LIM);

while(i<LIM && gets(temp))
{
if(temp[0]!='q')
printf("%s doesn't begin with q!\n",temp);
else
{
strcpy(qwords[i],temp);
i++;
}
}  
puts("Here are the words accepted:");

for(i=0;i<LIM;i++)
puts(qwords[i]);

return 0;
}
 本程序是:找到以q开头的输入单词,并显示q开头的单词。但是执行后并不显示以q开头的单词,求解答。

[解决办法]
能显示输入的以q开头的单词,楼主是不是哪里操作错误了。
[解决办法]
要五个一起显示
[解决办法]
没问题啊。。

C/C++ code
Enter 5 words beginning with q:qqqqqqqqqqqqqqqHere are the words accepted:qqqqqqqqqqqqqqq请按任意键继续. . . 

热点排行