在學習《C語言程序設計案例教程》的時候需要使用EasyX,需要使用Visual Studio開發環境。在C程序中使用#include <graphics.h>的時候出現了如下錯誤:
#include "pch.h"
#include <graphics.h>
#include <math.h>
#include <conio.h>
int main()
{
int x, y, r, t;
x = y = 100;
r = 80;
t = (int)(sqrt(2.0)*r / 2);
initgraph(640, 480);
circle(x, y, r);
rectangle(x - t, y - t, x + t, y + t);
_getch();
closegraph();
return 0;
}
解決的方法是去EasyX官網下載EasyX的exe程序,點擊后直接對自己使用的VC版本進行安裝就行了,很簡單。
運行結果如圖: