| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2261 人关注过本帖
标题:请问这句c语言的话到底怎么错了阿!
取消只看楼主 加入收藏
甜菜GENIUS
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-27
收藏
 问题点数:0 回复次数:6 
请问这句c语言的话到底怎么错了阿!

我写的这句CODE
typedef enum {LEMON=1,CHERRY,ORANGE,PLUM,BELL,BAR} symbalsT;
结果GCC的时候就有下面这句警告
为什么呀
我都是按照书上来的阿

warning: parameter names (without types) in function declaration

搜索更多相关主题的帖子: c语言 
2006-05-10 05:55
甜菜GENIUS
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-27
收藏
得分:0 
那么我应该在哪里加上数据类型呢?
typedef enum {LEMON=1,CHERRY,ORANGE,PLUM,BELL,BAR} symbalsT;
这个难道不应该直接就转换成整数了么
从1开始到6呀?????
2006-05-10 06:18
甜菜GENIUS
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-27
收藏
得分:0 


明白你说的了
但是整个CODE还是有2个错误。。。不能顺利GCC。。。。
头痛
把程序发上来大家谁能帮着看看
做一个老虎机样的东西
老师非要我们用typedef enum

#include <stdio.h>
#include "random.h"
#include "genlib.h"
#include "simpio.h"
#include "strlib.h"


typedef enum {LEMON=1,CHERRY,ORANGE,PLUM,BELL,BAR} symbalsT;

symbalsT calc_payout(symbalsT a symbalsT b symbalsT c);
bool Getyesorno(string prompt);
void Playslot();

int main()
{
int bal=50 ;
while(TRUE)
{
Playslot();
bal+=calc_payout();
printf("You have $%d.", bal);
if (!Getyesorno(" Would you like to play (n = no)?"));
break;
}//while
return 0;

}//main


void Playslot()
{
symbalsT a, b, c;
int pay;

a=RandomInteger(1,6);
b=RandomInteger(1,6);
c=RandomInteger(1,6);
pay = calc_payout(a,b,c);
if (pay>0)
printf("%8d %8d %8d -- You Win % %d", a,b,c,pay);
else
printf("%8d %8d %8d -- You lose ",a,b,c);
}//playslot

symbalsT calc_payout (a,b,c)
{
if (a==6&&b==6&&c==6) return 250;
if (a==5 &&b==5&& (c==5||6)) return 20;
if (a==4 &&b==4&& (c==4||6)) return 14;
if (a==3 &&b==3&& (c==3||6)) return 10;
if (a==2&& b==2 && c==2) return 7;
if ((a==2&& b==2)||(b==2&&c==2)||(a==2&&c==2)) return 5;
if (a==2||b==2||c==2) return 2;
else return -1;
return 0;

}//calc+payout

bool Getyesorno(string prompt)
{
string answer;

while (TRUE)
{
printf("%s",prompt);
answer=GetLine();
if (StringEqual(answer, "n"))
return (FALSE);
else
return (TRUE);
}//while
}// Getyesorno

2006-05-10 06:37
甜菜GENIUS
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-27
收藏
得分:0 
[wuzh@pc70 ~/p6]$ gcc -Wall -o 8.12.out Ch8_12.c cslib.a
Ch8_12.c:12: error: syntax error before 'symbalsT'
Ch8_12.c: In function 'Playslot':
Ch8_12.c:42: warning: conversion lacks type at end of format

出来的结果是这样。。。我实在是弄不好了。。呜呜
一整个下午都花在这个上面了。。。。
2006-05-10 06:39
甜菜GENIUS
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-27
收藏
得分:0 
不是阿
用的一个叫PUTTY在WIN XP下面用的阿
我现在在国外学C的
跟中文的系统也许不同吧。。。。。。我GCC之后确实只有2个WARNING的
不过能不能运行我估计是不行
STRING还没弄清楚
2006-05-10 06:58
甜菜GENIUS
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-27
收藏
得分:0 
呼呼。。。。终于在去掉
typedef enum {LEMON=1,CHERRY,ORANGE,PLUM,BELL,BAR} symbalsT;
这个的情况下。让它运行了
可。。。。怎么把数字转换成字母显示出来啊?????
2006-05-10 08:23
甜菜GENIUS
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-27
收藏
得分:0 
谢谢各位了
问题已经解决了
嘻嘻
2006-05-13 15:47
快速回复:请问这句c语言的话到底怎么错了阿!
数据加载中...
 
   



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

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