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开头的单词,楼主是不是哪里操作错误了。
[解决办法]
要五个一起显示
[解决办法]
没问题啊。。
Enter 5 words beginning with q:qqqqqqqqqqqqqqqHere are the words accepted:qqqqqqqqqqqqqqq请按任意键继续. . .