C语言,结束while循环问题。

//这是一个投票统计程序 # include<stdio.h> # include<windows.h> struct struvote{char name[10]; int votes;}candidate[3]; //存储三名选手的名字,得票 int main() { int i; char vote[10]; for(i=0;i<3;i++) { candidate[i].votes=0; printf("请输入第%d号选手的名字:",i+1); scanf("%s",&candidate[i].name); } i=1; printf("************************************************\n"); printf("请输入选手名字进行投票,按end结束投票\n\n"); fflush(stdin); while(vote!="end") { printf("请输入第%d张选票:",i++); gets(vote); } system("pause"); } 我想在输入end的时候结束循环,可是一直都结束不了,为什么呢?

第1个回答  2020-03-20
字符串不应该用!=比较
#include<string.h>
while(strcmp(vote,"end"))
已经试验过了,你试试

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网