| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 787 人关注过本帖
标题:[求助]关于枚举类型
取消只看楼主 加入收藏
Apple_skm
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-8-10
收藏
 问题点数:0 回复次数:0 
[求助]关于枚举类型

各位大虾,请帮忙看看下面的程序错 在哪
#include <stdio.h>
#include <string.h>
#define FALSE 0
#define TRUE 1
#define LEN 30
enum spectrum {red, orange, yellow, green, blue, violet};
const char * colors[] = {"red", "orange", "yellow",
"green", "blue", "violet"
};

int main (void)
{
char choice[LEN];
enum spectrum color;
int che;

puts ("Enter a color (empty line to quit): ");
while (gets (choice) != NULL && choice[0] != '\0')
{
for (color = red; color <= violet; color ++)
{
if (strcmp (choice,colors[color]) == 0)
{
che = TRUE;
break;
}
}
if (che);
switch (color)
{
case red : puts ("Roses are red.");
break;
case orange : puts ("Poppies are orange.");
break;
case yellow : puts ("Sunflowers are yellow.");
break;
case green : puts ("Grass is green.");
break;
case blue : puts ("Bluebells are blue.");
break;
case violet : puts ("Violet are violet.");
break;
}
else
printf ("I don't know about the color %s.\n", choice);
che = FALSE;
puts ("Next color, please(empty line to quit): ");
}
puts ("Goodbye!");

return o}

搜索更多相关主题的帖子: 类型 枚举 
2006-08-20 11:21
快速回复:[求助]关于枚举类型
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015916 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved