
C++头文件(No such file or directory)
版本:VisualC++6.0(SP6)过程:1新建Win32ConsoleApplicationc:\1104(保存路径)1104(文件名)2新建C/C++Header...
版本:Visual C++ 6.0(SP6)
过程:
1 新建Win32 Console Application c:\1104(保存路径) 1104(文件名)
2 新建C/C++ Header File c:\1104(保存路径) 1104(文件名)
3 新建C++ Source File c:\1104(保存路径) 1104(文件名)
4 附2 3的程序代码(见后附)
编译提示信息
--------------------Configuration: 1104 - Win32 Debug--------------------
Compiling...
1104.cpp
c:\program files\microsoft visual studio\myprojects\1104\1104.cpp(5) : fatal error C1083: Cannot open include file: 'shape.h': No such file or directory
执行 cl.exe 时出错.
1104.obj - 1 error(s), 0 warning(s)
---请问这是怎么回事呢?错出在哪里呢?
盼赐教,谢谢
附:
4 附2 3程序代码
//***************
//* shape.h *
//***************
#include "math.h"
const double pi=3.14159265358;
struct cirle
{
double r;
};
struct square
{
double a;
};
struct rectangle
{
double a,b;
};
struct triangle
{
double a,b,c,alpha,beta,gamma;
};
double rerimeter_of_circle(double r)
{
return 2*pi*r;
};
double area_of_circle(double r)
{
return pi*r*r;
};
double perimer_of_square(double a)
{
return 4*a;
};
double area_of_square(double a)
{
return a*a;
};
double perimeter_of_rectangle(double a,double b)
{
return 2*(a+b);
};
double area_of_rectangle(double a,double b)
{
return a*b;
};
double perimeter_of_triangle(double a,double b,double c)
{
return a+b+c;
};
double area_of_triangle(double a,double b,double gamma)
{
return sin(gamma/180*pi)*a*b/2;
};
//*************
//* main.cpp *
//*************
#include "iostream.h"
#include "shape.h"
int main()
{
circle c={2};
square s={1};
rectangle r={2,3};
triangle t={3,4,5,36.86989,53.13011,90};
cout <<"Perimeter of circle " <<perimeter_of_circle(c.r) <<endl;
cout <<"Area of square "<<area_of_square(s.a) <<endl;
cout <<"Perimeter of rectangle " <<pertimeter_of_rectangle(r.a,r.b) <<endl;
cout <<"Area of triangle " <<area_of_triangle(t.b,t.c,t.alpha) <<endl;
return 0;
}
存储路径应为:
c:\program files\microsoft visual studio\myprojects
(提问的时候偷懒造成的,见笑)
1105 09:30
谢谢各位的回答。
但是我还是没有发现我的错误所在,有没有朋友能够给个可执行修改稿呢?
1 3137333
使用了工程。
创造的第一个文件就是个工程。
2 windseeker2007
你认为应该怎么修改呢?
3 禾勹彐心
在我的书上关于头文件的规则讲得很少,需要你具体的指导
1107
4
致leilwang:
谢谢你的答案。但是我还是很遗憾的告诉你,我把你的程序代码复制-粘贴后进行编译,出现同样的错误提示---Cannot open include file: 'shape.h': No such file or directory
执行 cl.exe 时出错.
如果我们确定在语法格式、算法思路上不存在问题,那问题又是出在哪里呢? 展开
过程:
1 新建Win32 Console Application c:\1104(保存路径) 1104(文件名)
2 新建C/C++ Header File c:\1104(保存路径) 1104(文件名)
3 新建C++ Source File c:\1104(保存路径) 1104(文件名)
4 附2 3的程序代码(见后附)
编译提示信息
--------------------Configuration: 1104 - Win32 Debug--------------------
Compiling...
1104.cpp
c:\program files\microsoft visual studio\myprojects\1104\1104.cpp(5) : fatal error C1083: Cannot open include file: 'shape.h': No such file or directory
执行 cl.exe 时出错.
1104.obj - 1 error(s), 0 warning(s)
---请问这是怎么回事呢?错出在哪里呢?
盼赐教,谢谢
附:
4 附2 3程序代码
//***************
//* shape.h *
//***************
#include "math.h"
const double pi=3.14159265358;
struct cirle
{
double r;
};
struct square
{
double a;
};
struct rectangle
{
double a,b;
};
struct triangle
{
double a,b,c,alpha,beta,gamma;
};
double rerimeter_of_circle(double r)
{
return 2*pi*r;
};
double area_of_circle(double r)
{
return pi*r*r;
};
double perimer_of_square(double a)
{
return 4*a;
};
double area_of_square(double a)
{
return a*a;
};
double perimeter_of_rectangle(double a,double b)
{
return 2*(a+b);
};
double area_of_rectangle(double a,double b)
{
return a*b;
};
double perimeter_of_triangle(double a,double b,double c)
{
return a+b+c;
};
double area_of_triangle(double a,double b,double gamma)
{
return sin(gamma/180*pi)*a*b/2;
};
//*************
//* main.cpp *
//*************
#include "iostream.h"
#include "shape.h"
int main()
{
circle c={2};
square s={1};
rectangle r={2,3};
triangle t={3,4,5,36.86989,53.13011,90};
cout <<"Perimeter of circle " <<perimeter_of_circle(c.r) <<endl;
cout <<"Area of square "<<area_of_square(s.a) <<endl;
cout <<"Perimeter of rectangle " <<pertimeter_of_rectangle(r.a,r.b) <<endl;
cout <<"Area of triangle " <<area_of_triangle(t.b,t.c,t.alpha) <<endl;
return 0;
}
存储路径应为:
c:\program files\microsoft visual studio\myprojects
(提问的时候偷懒造成的,见笑)
1105 09:30
谢谢各位的回答。
但是我还是没有发现我的错误所在,有没有朋友能够给个可执行修改稿呢?
1 3137333
使用了工程。
创造的第一个文件就是个工程。
2 windseeker2007
你认为应该怎么修改呢?
3 禾勹彐心
在我的书上关于头文件的规则讲得很少,需要你具体的指导
1107
4
致leilwang:
谢谢你的答案。但是我还是很遗憾的告诉你,我把你的程序代码复制-粘贴后进行编译,出现同样的错误提示---Cannot open include file: 'shape.h': No such file or directory
执行 cl.exe 时出错.
如果我们确定在语法格式、算法思路上不存在问题,那问题又是出在哪里呢? 展开
11个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |