| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2096 人关注过本帖
标题:编译成功且未提示有任何错误但运行时提示Bad command or filename是怎么回事 ...
只看楼主 加入收藏
bluesky3810
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2007-9-17
收藏
 问题点数:0 回复次数:8 
编译成功且未提示有任何错误但运行时提示Bad command or filename是怎么回事?

这是Kochan所编的<<Programming in C>>中的一个例题,但运行时为什么回出现如题状况呢?我所采用的运行平台为Turbo C for Windows.换用其它运行平台时依然如此.我的文件命名应该没问题的啊,文件名为dateUpdate.C

#include <stdio.h>
#include <stdbool.h>

struct date
{
int month;
int day;
int year;
};

int main(void)
{
struct date today,tomorrow;
int numberOfDays(struct date d);
printf ("please type in today's date(mm dd yyyy):");
scanf ("%i%i%i",&today.month,&today.day,&today.year);

if (today.day != numberOfDays(today))
{
tomorrow.day=today.day+1;
tomorrow.month=today.month;
tomorrow.year=today.year;
}
else if (today.month == 12)
{
tomorrow.day=1;
tomorrow.month=1;
tomorrow.year=today.year + 1;
}
else
{
tomorrow.day=1;
tomorrow.month=today.month + 1;
tomorrow.year=today.year;
}
printf ("tomorrow's date is %i/%i/%.2i.\n",tomorrow.month,tomorrow.day,tomorrow.year % 100);
return 0;
}

/*判断是否为闰年的函数*/
bool isLeapYear(struct date d)
{
bool LeapYearFlag;
if (d.year % 4 ==0 && d.year % 100 != 0 || d.year % 400 == 0)
LeapYearFlag = true;
else
LeapYearFlag = false;
return LeapYearFlag;
}

/*查找一个月中日期数的函数*/
int numberOfDays (struct date d)
{
int days;
bool isLeapYear (struct date d);
const int daysPerMonth[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
if (isLeapYear(d) == true && d.month == 2)
days = 29;
else
days = daysPerMonth[d.month - 1];
return days;
}




搜索更多相关主题的帖子: command Bad filename int date 
2007-10-22 17:18
caohuolong
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2007-6-11
收藏
得分:0 
  DEV C++ 下面 可以成功编译和运行!

2007-10-22 18:17
栖柏
Rank: 2
等 级:论坛游民
威 望:3
帖 子:1103
专家分:17
注 册:2007-8-23
收藏
得分:0 
bool????
用c++编译器,把文件名改为.cpp

You have lots more to work on! Never give up!c language!
2007-10-22 18:26
bluesky3810
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2007-9-17
收藏
得分:0 
以下是引用caohuolong在2007-10-22 18:17:58的发言:
在 DEV C++ 下面 可以成功编译和运行!

那确实,我也试了一下,为什么会这样呢?怎么DEV CPP下没问题,而TURBO C却不行呢?我明明用的是C教程啊

2007-10-22 22:39
bluesky3810
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2007-9-17
收藏
得分:0 

我刚刚看了一下安装目录,发现INCLUDE文件夹中根本就没有头文件stdbool.h是这个头文件的确实导致的吗?该如何解决,头文件有没有什么地方可以下载扩充.

2007-10-22 22:59
bluesky3810
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2007-9-17
收藏
得分:0 

难道没有人知道吗?急救~~~~~

2007-10-23 10:27
kingkino
Rank: 1
等 级:新手上路
帖 子:83
专家分:0
注 册:2007-10-18
收藏
得分:0 

汗,我用的也是这个编译器,也是报这个错.....
有的时候同样的程序,文件名长点就报错,重命名个短点的名字 就好了 完全不知道为什么.....


2007-10-23 15:30
yangzhifu
Rank: 1
等 级:新手上路
威 望:2
帖 子:433
专家分:0
注 册:2007-4-11
收藏
得分:0 
我也有错找不到stdbool.h
Cannot open include file: 'stdbool.h': No such file or directory
我还没看见过它,说实话,vc下没有它,看看gcc有不

方寸之内,剖天下; 方坛之内,析自我;
2007-10-23 18:25
bluesky3810
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2007-9-17
收藏
得分:0 

见鬼了,这老外用的什么编译器啊?
DEV CPP可以运行,但是在Include文件夹中也找不到stdbool.h文件
真的是搞坨不清.

2007-10-23 18:50
快速回复:编译成功且未提示有任何错误但运行时提示Bad command or filename是怎 ...
数据加载中...
 
   



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

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