我有一个这样的C程序,#include<dos.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>#define command_8253 0x43
#define timer_8253  0x40void interrupt (*oldproess)();
void interrupt proess();
void modify_8253();
void restore_8253();
double v1=0,v2=0;
int basea=0x280,firstchannel=0,nextchannel=1;void main()
{
   FILE *fp;
   char str[]={"d:\\user"};   if(chdir(str)==0)
   {printf("ok,start collect data\n");}
   else
   { system("cd\\");
     system("d:");
     system("md user");
     system("cd user");
   }
     if((fp=fopen("d:\\user\\2.txt","w"))==NULL)
     {exit(0);}
  system("cls");
  modify_8253();
  do{
    sleep(1);    printf("--------------------------------------\n");
    printf("the first  data: \t");
    printf("%.3f\n",v1);
    printf("the second data: \t");
    printf("%.3f\n",v2);
    fprintf(fp,"%f,%f\n",v2,v1);
  }while(!kbhit());
  close(fp);
  restore_8253();
  getch();
}void interrupt proess(void)
{
  int i,num1,num2,volt1=0,volt2=0;
  disable();
   for(i=0;i<20;i++)       /*the first*/
  {  outportb(basea,firstchannel);
   }
  do{  }while( !inp(basea+5)&0x80 ) ;
  num1=inportb(basea+1);
  num2=inportb(basea+2)&0x0f;
  volt1=num1+num2*256;
  v1=(v1*300+volt1)/301;
         /*the second*/
     for(i=0;i<20;i++)       /*the first*/
  {  outportb(basea,nextchannel);
   }
  do{  }while( !inp(basea+5)&0x80 ) ;
  num1=inportb(basea+1);
  num2=inportb(basea+2)&0x0f;
  volt2=num1+num2*256;
  v2=(v2*300+volt2)/301;
  outportb(0x20,0x20);
  enable();
}void modify_8253()
{
 disable();
 oldproess=getvect(0x8);
 outportb(command_8253,0x36);
 outportb(timer_8253,0x51);
 outportb(timer_8253,0x09);
 setvect(0x8,proess);
 enable();
}
void restore_8253()
{
 disable();
 setvect(0x8,oldproess);
 outportb(command_8253,0x36);
 outportb(timer_8253,0xff);
 outportb(timer_8253,0xff);
 enable();
}这是一个数据采集的程序,是用C编的,但是,现在我需要把它在VISUAL C++下通过,我试了几次,都有错误,请问,我如何才能把它在VISUAL C++下通过呢。原程序我已经给出了。如果有必要,请在VISUAL C++下写出来,发到

解决方案 »

  1.   

    win32的平台    i/o直接????
      

  2.   

    在WIN32环境下采用保护模式, 直接I/O存取是不被允许的!你是从那里翻出来的书啊? int21, int86 这样的中断方式都已经"失传"好多年了:)
      

  3.   

    这是我们实验室一个机子上装有老式的数据采集卡需要的程序,我好不容易,找资料,才把这个弄出来的,但是,在DOS下还是不怎么好用,我想用VC试一下,但是,不知道如何下手了。请大家指教。   有没有办法呢。
      

  4.   

    c程序向C++移植的一主要难点在于C++编译器对类型检查比C的编译器要严格的多,尤其对其它类型向void类型的转换在C++是不允许的。其它应该没有什么问题,库都是兼容的。对注意编译器给出的出错信息。
      

  5.   

    #include<conio.h>
    明显是TC的程序,你用TC吧
    #include<dos.h>
    明显是DOS下的程序
    现在VC几乎都是编写WINDOWS程序,你想想要包含DOS,就应该用DOS下编程的工具,比如TC
      

  6.   

    楼上这位大哥, lkcowboy(三黑) ,这个问题我知道,但是,我想把这个改在VC下,怎么改,我改不了啊。
      

  7.   

    没事呀,这不就是C/C++程序吗?
    #include<dos.h>
    #include<conio.h>要不你用VC Console建立项目,进行代码Copy即可
      

  8.   

    nbgyf(小蜜蜂) ,不用这个不可以吗??这个和DOS下还是没有太大区别啊。我想用WIN下的窗口啊。
      

  9.   

    有void main()就是console用WIN下的窗口,入口函数是WinMain:int WINAPI WinMain(
      HINSTANCE hInstance,  // handle to current instance
      HINSTANCE hPrevInstance,  // handle to previous instance
      LPSTR lpCmdLine,      // pointer to command line
      int nCmdShow          // show state of window
    );只能学习其中的结构,重新写一个