c++ - Visual Studio C++ 中的 DDALine

标签 c++ visual-c++

我用C++在Visual-Studio中写了DDALine算法,但是Visual-Studio说

'putpixel': identifier not found.....

我正在使用 graphics.h,但是不起作用 ??

我的源代码

#include "graphics.h"
#include "stdlib.h"
#include "stdio.h"
#include "conio.h"
#include "dos.h"
#include "stdafx.h"
#include "math.h"

void ddaline(int x1,int y1,int x2,int y2,int color)
{

int dx,dy,len,i;
float xinc,yinc,x,y;
dx=x2-x1;
dy=y2-y1;
if (abs(dx)>abs(dy))
len=abs(dx);
else
len=abs(dy);
     if (len!=0)
{
xinc=((dx*1.0)/(len));
yinc=((dy*1.0)/(len));
 }
 x=x1;
 y=y1;
  for(i=0;i<=len;i++)
  {
  putpixel(x,y,color);
  x=x+xinc;
  y=y+yinc;
  }

       }
     void main()
  {

 ddaline(1,1,640,400,4);



  }

最佳答案

<graphics.h><conio.h>不是 C++ 标准头文件。你的项目旁边有它们吗?!

你应该在 Turbo C++ 和 DOSBOX 中测试你的代码(新的 Windows 版本不支持 DOS 全屏模式)

关于c++ - Visual Studio C++ 中的 DDALine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15223975/

相关文章:

c++ - 无法推断重载函数的模板参数

C++ - 将 exe 转换为源代码

c++ - 从非版本控制文件夹移动到版本控制文件夹后,VC++ VS2013 项目无法编译

c++ - 如何使用libpqxx正确选择日期字段?

c++ - 如何将 DLL 反转为 C++ 代码?

c++ - 错误: C2057: expected constant expression

c++ - 使用 C++ 创建 MetaTrader Terminal 4 DLL 文件

c++ - 我可以在使用前定义吗

C++:为什么无法在派生类中访问 protected 构造函数?

c++ - BFS中队列大小的重要性