2017-08-29 4 views
-2

コンテキスト 言語:C++ 、エディタ:マイクロソフトのVisual Studioのコードバージョン1.15.1Graphics.hはVSコードのバージョンで動作しない1.15.1

問題私は、Microsoft Visual Studioのコードバージョンを使用しています C++プログラムをコンパイルするための1.15.1。 Graphics.hを使用してC++プログラムでGraphicsを使用したいだから私は3つのファイルGraphics.h、winbgim.h、libbgi.aをダウンロードし、それらを正しい場所に入れたのです。また、https://www.cs.colorado.edu/~main/bgi/visual/BGI2010.zipからBGIフォルダをダウンロードし、それを正しい場所に置きます。しかし、自分のプログラムをコンパイルするときに、何らかのエラーが表示されます。

私のC++プログラム私のプログラムの

#include<iostream> 
    #include<math.h> 
    #include<graphics.h> 
    using namespace std; 
    int main(){ 
     int x,y; 
     int gd = DETECT ,gm; 
     initgraph(&gd,&gm,"C:\\MinGW\bgi"); 
     cout<<"Enter the Value of X Co-ordinate : "; 
     cin>>x; 
     cout<<"Enter the Value of Y Co-ordinate : "; 
     cin>>y; 
     putpixel(x,y,WHITE); 
     closegraph(); 
    } 

エラー

computerGraphics1.cpp: In function 'int main()': 
computerGraphics1.cpp:8:25: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] 
    initgraph(&gd,&gm,"C:\\MinGW\bgi"); 
         ^
C:\Users\TUSK\AppData\Local\Temp\ccEbDqZq.o: In function `main': 
C:\Users\TUSK\Desktop\Practise\C++ Projects/computerGraphics1.cpp:8: undefined reference to `initgraph' 
C:\Users\TUSK\Desktop\Practise\C++ Projects/computerGraphics1.cpp:13: undefined reference to `putpixel' 
C:\Users\TUSK\Desktop\Practise\C++ Projects/computerGraphics1.cpp:14: undefined reference to `closegraph' 
collect2.exe: error: ld returned 1 exit status 

だから、今までそのソリューションを検索Guysはそれを

+1

」ヘッダーとライブラリは古いものであり、廃止されています。そして、定数でない文字列へのポインタを許可するC用に作られました。 C++では、すべてのリテラル文字列定数は次のとおりです。*** Constant ***。 'initgraph'は定数ではない文字列へのポインタを取るので(警告はリテラル文字列が読み込み専用であっても、C言語では有効です)、警告*が表示されます。 –

答えて

0

を回答してくださいあなたは "修正" することができますconst_castのエラーですが、ifこれまでにクラッシュする文字列の内容を変更しようとしています。

+0

大きな問題はおそらく、さまざまな 'graphics.h'関数のリンカエラーです。 – ComicSansMS

関連する問題