当前位置: 代码迷 >> C语言 >> 编译成功且未提示有任何错误但运行时提示Bad command or filename是怎么回事 ...
  详细解决方案

编译成功且未提示有任何错误但运行时提示Bad command or filename是怎么回事 ...

热度:948   发布时间:2007-10-22 17:18:03.0
编译成功且未提示有任何错误但运行时提示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  

----------------解决方案--------------------------------------------------------
在  DEV C++ 下面 可以成功编译和运行!
----------------解决方案--------------------------------------------------------
bool????
用c++编译器,把文件名改为.cpp

----------------解决方案--------------------------------------------------------
以下是引用caohuolong在2007-10-22 18:17:58的发言:
在 DEV C++ 下面 可以成功编译和运行!

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


----------------解决方案--------------------------------------------------------

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


----------------解决方案--------------------------------------------------------

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


----------------解决方案--------------------------------------------------------

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


----------------解决方案--------------------------------------------------------
我也有错找不到stdbool.h
Cannot open include file: 'stdbool.h': No such file or directory
我还没看见过它,说实话,vc下没有它,看看gcc有不
----------------解决方案--------------------------------------------------------

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


----------------解决方案--------------------------------------------------------
  相关解决方案