0

当我尝试在 Visual Studio 2019 中使用 graphics.h 绘制线条时,我不断收到两种类型的错误。

这是我试图从 geeksforgeeks.org 开始使用我的编译器的示例

错误

E0167 - “const char*”类型的参数与“char*”类型的谎言 2 参数不兼容 - 第 17 行

C2664 - 'void initgraph(int*,int*,char*)'; 无法将参数 3 从 'const char[1] 转换为 'char*' - 第 17 行

我的代码:

'''// C++ Implementation for drawing line 
#include <graphics.h> 

// driver code 
int main()
{
    // gm is Graphics mode which is a computer display 
    // mode that generates image using pixels. 
    // DETECT is a macro defined in "graphics.h" header file 
    int gd = DETECT, gm;

    // initgraph initializes the graphics system 
    // by loading a graphics driver from disk 
    initgraph(&gd, &gm, "");

    // line for x1, y1, x2, y2 
    line(150, 150, 450, 150);

    // line for x1, y1, x2, y2 
    line(150, 200, 450, 200);

    // line for x1, y1, x2, y2 
    line(150, 250, 450, 250);

    getch();

     // closegraph function closes the graphics 
    // mode and deallocates all memory allocated 
    // by graphics system . 
    closegraph();
}'''
4

0 回答 0