Compile a DOS C++ file in Windows - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Compile a DOS C++ file in Windows

darklingduckdarklingduck Posts: 8Member
Hello,

I need to compile a C++ file so that it will run in a DOS environment. I am currently using Visual C++. Is there a setting that I cna change to make it compile a DOS file?

Thanks

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]Latest VC++ is only for Windows.

    You need a DOS compiler, I mean the old compiler, like Turbo C++ or Visual C++ 1.5 or something like that... (Watcom DOS works too)[/color]
  • darklingduckdarklingduck Posts: 8Member
    Thanks for the information. Will I be able to run the Watcom DOS program from within Windows? I don't have a DOS box to install it onto.
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]Windows has a DOS Virtual Machine (NTVDM). Most of DOS application code will run fine inside it, however, if the code does some hardware things, like writing to ports, which are "owned" by Windows or some other driver level code - this will not work properly inside NTVDM.

    My old Turbo C graphics programs from the 90s are still running fine.[/color]
  • darklingduckdarklingduck Posts: 8Member
    Hello,

    Any way I can get a little help here? Getting the following errors when trying to compile my CPP file for DOS:

    [color=Blue]cd C:WATCOM
    wmake -f C:WATCOMPPID_Update.mk -h -e -a C:WATCOMPPID_update.obj
    wpp PPID_update.cpp -i="C:WATCOM/h" -w4 -e25 -zq -od -d2 -bt=dos -fo=.obj -ml -xs -xr
    PPID_update.cpp(76): Error! E029: col(41) symbol 'getline' has not been declared
    PPID_update.cpp(113): Error! E029: col(41) symbol 'getline' has not been declared
    PPID_update.cpp(133): Error! E157: col(33) left expression must be integral
    PPID_update.cpp(133): Note! N717: col(33) left operand type is 'std::ofstream (lvalue)'
    PPID_update.cpp(133): Note! N718: col(33) right operand type is 'std::basic_string,std::allocator>'
    Error(E42): Last command making (C:WATCOMPPID_update.obj) returned a bad status
    Error(E02): Make execution terminated
    Execution complete[/color]

    Here is the source file:

    [code]
    // my first program in C++

    #include
    #include
    #include
    #include
    #include
    using namespace std;

    string BeginLine, PartNum, EndLine, Rev;

    string UCase (string Begin) {

    int LineLen = 0, I;

    for(I=0; I<=Begin[I]; I++)
    LineLen++;

    for (I=0; I < LineLen+1; I++){
    if((Begin[I]>=97) && (Begin[I]<=122)){
    Begin[I]=Begin[I]-32;
    }
    }

    return Begin;

    }

    int UCase1 () {

    int I;

    for (I=0; I < 3; I++){
    if((BeginLine[I]>=97) && (BeginLine[I]<=122)){
    BeginLine[I]=BeginLine[I]-32;
    }
    }

    for (I=0; I < 3; I++){
    if((Rev[I]>=97) && (Rev[I]<=122)){
    Rev[I]=Rev[I]-32;
    }
    }

    for (I=0; I < 5; I++){
    if((PartNum[I]>=97) && (PartNum[I]<=122)){
    PartNum[I]=PartNum[I]-32;
    }
    }

    for (I=0; I < 12; I++){
    if((EndLine[I]>=97) && (EndLine[I]<=122)){
    EndLine[I]=EndLine[I]-32;
    }
    }

    return 0;
    }

    int PartChange () {

    string PartLine, OldPart, NewPart;

    BeginLine = UCase(BeginLine);
    PartNum = UCase(PartNum);
    EndLine = UCase(EndLine);
    Rev = UCase(Rev);

    // UCase1();
    ifstream myfile3 ("PartNums.txt");

    if (myfile3.is_open())
    {
    while (! myfile3.eof() )
    {
    getline (myfile3,PartLine);
    OldPart = PartLine.substr(0,5);
    NewPart = PartLine.substr(6,5);

    if (PartNum == OldPart) {
    PartNum = NewPart;
    }
    }
    }

    else cout << "Unable to open file";

    // if (PartNum =="M3849") {
    // PartNum ="FH175";
    // }

    return 0;
    }

    int main () {
    string FullLine, PartLine, SampleLine1, SampleLine2;

    // Open Output File
    ofstream myfile2 ("Update.bat");
    // Open Input File
    ifstream myfile1 ("TEST.txt");

    SampleLine1 = "Sysbrd Ser# => ";
    SampleLine2 = "Sysbrd Ver => ";
    // PartLine="0";

    if (myfile2.is_open())
    {
    if (myfile1.is_open())
    {
    while (! myfile1.eof() )
    {
    getline (myfile1,FullLine);
    PartLine = FullLine.substr(0,15);

    if ( SampleLine1 == PartLine )
    {
    BeginLine = FullLine.substr(15,3);
    PartNum = FullLine.substr(18,5);
    EndLine = FullLine.substr(23,12);
    }

    if ( SampleLine2 == PartLine )
    {
    Rev = FullLine.substr(15,3);
    }

    }

    myfile1.close();

    PartChange();
    myfile2 << "asset /b " +BeginLine + PartNum + EndLine + "-" + Rev + " /f" << endl;

    myfile2.close();
    }

    else cout << "Unable to open file";

    }

    else cout << "Unable to open file";

    return 0;

    }[/code]

    Thanks
Sign In or Register to comment.