你可以检查以下编码我得到[错误] iostream.H:没有终止此类文件或目录编译 [英] Can You Please Check This Below Coding I Am Getting [Error] iostream.H: No Such File Or Directory Compilation Terminated

查看:546
本文介绍了你可以检查以下编码我得到[错误] iostream.H:没有终止此类文件或目录编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  #include   <   iostream.h  >  
#include < conio.h >
#include < graphics.h >
#include < dos.h >
#include < process.h >
#include < stdlib.h >


void makecar( int x, int y)
{
rectangle(x + 1,y,x + 49,y + 100) );
矩形(x + 1,y + 25,x + 49,y + 75);
setfillstyle(SOLID_FILL, 8 );
floodfill((x + x + 50)/ 2,(y + y + 100)/ 2, 15 );
}


void clear( int x , int y)
{
setcolor( 8 );
矩形(x + 1,y,x + 49,y + 100);
矩形(x + 1,y + 25,x + 49,y + 75);
setfillstyle(SOLID_FILL, 8 );
floodfill((x + x + 50)/ 2,(y + y + 100)/ 2, 8 );
setcolor( 15 );
}


void main()
{
int 驱动程序,模式;
driver = DETECT;
initgraph(& driver,& mode, \\tc\\ bgi );
int x = 300 ,y = 350 ,ch,life = 3 ,得分= 0 ;
char choice;
cout<< \ n \ nn \ n \ n \ n t \\\\ * * THUNDER RACER *;
cout<< \ n \\\\\\\ ----------;
cout<< \ n \ n \\ n很久以前瓦伦西亚遭到袭击由;
cout<< \ n \ nn \\\ tenemies并被击败。每个士兵和公民是;
cout<< 除了美丽的Cindrella公主和你之外,其他人都不知道;
cout<< \ n \ n \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\她在你的;
cout<< \ n \ nn \ tcar现在。如果你有胆量救她脱离敌人的;
cout<< \ n\\\
\tcars并嫁给她。
;
cout<< \ n \ n \ t最好......< /跨度>;
延迟( 20000 );
for int m = 1 ; m< 25; m ++)
for int n = 1 ; n< 80; n ++){
gotoxy(n,m);
cout<< ;
}
setcolor(RED);
矩形( 20 60 200 120 );
矩形( 20 300 200 420 );
gotoxy( 5 21 );
cout<< 只有Ameya& Prateek;
gotoxy( 5 22 );
cout<< 将她保存到;
gotoxy( 5 23 );
cout<< 现在。所以你可以;
gotoxy( 5 24 );
cout<< 3-rd;
矩形( 249 0 401 < /跨度>,getmaxy());
setfillstyle(SOLID_FILL, 8 );
floodfill( 325 ,getmaxy()/ 2,RED);
setcolor(RED);
矩形( 20 200 200 250 );
gotoxy( 5 15 );
cout<< 按< esc>退出;
for int level = 1 ;(level< = 5 )&&(life> 0); level ++){
if (level == 1 ){
gotoxy( 5 5 );
cout<< 你的战争现在开始;
gotoxy( 5 7 );
cout<< 所有最好的;
延迟( 5000 );
gotoxy( 5 5 );
cout<< ;
gotoxy( 5 7 );
cout<< ;
}
else {
gotoxy( 5 5 );
cout<< 下一级。;
延迟( 5000 );
gotoxy( 5 5 );
cout<< ;
}
for int i = 0 ;(i< 15)&&(life> 0); i ++){
if ((level == 5 )&&(i == 14 )){
gotoxy( 5 5 );
cout<< 你赢了;
gotoxy( 5 6 );
cout<< 想继续;
cin>> choice;
if ((choice == ' y ')||(choice == ' Y'))
main ();
else
exit( 0 );
}
setcolor(RED);
矩形( 420 125 600 175 );
gotoxy( 55 10 );
cout<< Level =<< level;
矩形( 420 250 600 300 );
gotoxy( 55 18 );
cout<< Lives =<< life;
矩形( 420 350 600 400 );
gotoxy( 55 24 );
cout<< Score =<< score;
int accident = 0 ;
int y1 = 1 ,x1 = 250 +((rand()%3)* 50 );
int y2 = 1 ,x2 = 250 +((rand()%3)* 50 );
得分+ = 10 ;
while (y1< getmaxy() - 1 )>
{
clear(x1,y1);
clear(x2,y2);
y1 ++;
y2 ++;
makecar(x1,y1);
makecar(x2,y2);
makecar(x,y);
延迟( 5 -level);
if (kbhit())
{
makecar(x,y);
ch = getch();
switch (ch){
case 27 :退出( 0 );
break ;
case 75 :clear(x,y);
if (x> 250)
x = x- 50 ;
makecar(x,y);
break ;
case 77 :clear(x,y);
if (x <350)
x = x + 50;
makecar(x,y);
break ;
}
}
如果((x == x1)||(x == x2))
< span class =code-keyword> if
((((y-y1)< 100)&&((y-y1)> 0))||(((y-y2) < 100)&&((y-y2)> 0)))
accident = 1 ;


}
如果(意外== 1 ){
life = life- 1 ;
得分 - = 10 ;
if (life == 0 ){
gotoxy( 5 5 );
cout<< GAME OVER;
gotoxy( 5 6 );
cout<< 你无法保存;
gotoxy( 5 7 );
cout<< 她的;
break ;
}
gotoxy( 5 5 );
cout<< 你失去了1条生命;
延迟( 3000 );
gotoxy( 5 5 );
cout<< ;
}
}
}
getch();
}



解决方案

iostream 是一个C ++ STL标题,没有 .h 后缀。


这是一个旧源代码(可能与borland一起使用 turbo C ++ )。现代 C ++ 编译器具有标准头文件,没有 .h 扩展名(例如 iostream.h 现在只是 iostream )而 C 特定的头文件没有 .h c 前缀(例如 stdlib.h 现在 cstdlib )。在任何情况下,这样的代码都不会编译,因为,例如,系统上(很可能)没有BGI(提供 graphics.h 标头的库)。


你能不能试试



  #include   <   iostream  >   


#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<process.h>
#include<stdlib.h>


void makecar(int x, int y)
 {
  rectangle(x+1,y,x+49,y+100);
  rectangle(x+1,y+25,x+49,y+75);
  setfillstyle(SOLID_FILL,8);
  floodfill((x+x+50)/2,(y+y+100)/2,15);
  }


void clear(int x,int y)
 {
 setcolor(8);
 rectangle(x+1,y,x+49,y+100);
 rectangle(x+1,y+25,x+49,y+75);
 setfillstyle(SOLID_FILL,8);
 floodfill((x+x+50)/2,(y+y+100)/2,8);
 setcolor(15);
 }


void main()
 {
  int driver,mode;
  driver = DETECT;
  initgraph(&driver,&mode,"\\tc\\bgi");
  int x=300,y=350,ch,life=3,score=0;
  char choice;
  cout<<"\n\n\n\n\n\t\t\t* THUNDER RACER *";
  cout<<"\n\t\t\t ---------------";
  cout<<"\n\n\tLong long ago the state of Valencia was attacked by the";
  cout<<"\n\n\tenemies and were defeated. Every soldier and citizen was";
  cout<<"\n\n\tkilled except the beautiful princess Cindrella  and you";
  cout<<"\n\n\twho survived. Enemies want to kill her and she is in your";
  cout<<"\n\n\tcar right now. If you have the guts save her from enemies'";
  cout<<"\n\n\tcars and marry her.";
  cout<<"\n\n\tSo all the best...";
  delay(20000);
  for(int m=1;m<25;m++)
	for(int n=1;n<80;n++) {
		gotoxy(n,m);
		cout<<" ";
		}
  setcolor(RED);
  rectangle(20,60,200,120);
  rectangle(20,300,200,420);
  gotoxy(5,21);
  cout<<"Only Ameya & Prateek";
  gotoxy(5,22);
  cout<<"have saved her till";
  gotoxy(5,23);
  cout<<"now. So you can be";
  gotoxy(5,24);
  cout<<"the 3-rd";
  rectangle(249,0,401,getmaxy());
  setfillstyle(SOLID_FILL,8);
  floodfill(325,getmaxy()/2,RED);
  setcolor(RED);
  rectangle(20,200,200,250);
  gotoxy(5,15);
  cout<<"Press <esc> to Exit";
  for(int level=1;(level<=5)&&(life>0);level++){
	if(level==1){
	  gotoxy(5,5);
	  cout<<"Your War Starts Now";
	  gotoxy(5,7);
	  cout<<"All the best";
	  delay(5000);
	  gotoxy(5,5);
	  cout<<"                    ";
	  gotoxy(5,7);
	  cout<<"            ";
	  }
	 else {
	     gotoxy(5,5);
	     cout<<"Next level.";
	     delay(5000);
	     gotoxy(5,5);
	     cout<<"           ";
	     }
  for(int i=0;(i<15)&&(life>0);i++) {
	if((level==5)&&(i==14)){
	   gotoxy(5,5);
	   cout<<"You have won";
	   gotoxy(5,6);
	   cout<<"Wanna continue ";
	   cin>>choice;
	   if ((choice=='y')||(choice=='Y'))
		main();
	   else
		exit(0);
	   }
	setcolor(RED);
	rectangle(420,125,600,175);
	gotoxy(55,10);
	cout<<"Level = "<<level;
	rectangle(420,250,600,300);
	gotoxy(55,18);
	cout<<"Lives = "<<life;
	rectangle(420,350,600,400);
	gotoxy(55,24);
	cout<<"Score = "<<score;
	int accident=0;
	int y1=1,x1=250+((rand()%3)*50);
	int y2=1,x2=250+((rand()%3)*50);
	score += 10;
	while(y1<getmaxy()-1)>
	{
		clear(x1,y1);
		clear(x2,y2);
		y1++;
		y2++;
		makecar(x1,y1);
		makecar(x2,y2);
		makecar(x,y);
		delay(5-level);
		if(kbhit())
		{
			makecar(x,y);
			ch=getch();
			switch(ch) {
			case 27: exit(0);
			break;
			case 75:clear(x,y);
				if(x>250)
					x=x-50;
				makecar(x,y);
			break;
			case 77:clear(x,y);
				if(x<350)
					x=x+50;
				makecar(x,y);
			break;
			}
		}
		if((x==x1)||(x==x2))
			if( ( ((y-y1)<100)&&((y-y1)>0) ) || ( ((y-y2)<100)&&((y-y2)>0) ) )
				accident=1;


	  }
	  if(accident==1){
	    life =life-1;
	    score -= 10;
	    if(life==0) {
	     gotoxy(5,5);
	     cout<<"GAME OVER ";
	     gotoxy(5,6);
	     cout<<"You could not save";
	     gotoxy(5,7);
	     cout<<"her";
	     break;
	     }
	    gotoxy(5,5);
	    cout<<"You have lost 1 life";
	    delay(3000);
	    gotoxy(5,5);
	    cout<<"                    ";
	    }
  }
  }
 getch();
 }


解决方案

iostream is a C++ STL header and does not have the .h suffix.


That is an old source code (possibly working with borland turbo C++). Modern C++ compilers have standard header files without the .h extension (e.g. iostream.h is now simply iostream) while C specific header files have no .h and a c prefix (e.g. stdlib.h is now cstdlib). In any case such code wouldn't compile, because, for instance, there is (most likely) no BGI (the library providing the graphics.h header) on your system.


Could you please try like

#include <iostream>


这篇关于你可以检查以下编码我得到[错误] iostream.H:没有终止此类文件或目录编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆