MS-DOS

Moderators: blip
Number of threads: 389
Number of posts: 904

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Compile a DOS C++ file in Windows Posted by darklingduck on 8 Apr 2009 at 1:30 PM
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
Report
Re: Compile a DOS C++ file in Windows Posted by AsmGuru62 on 9 Apr 2009 at 4:30 AM
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)
Report
Re: Compile a DOS C++ file in Windows Posted by darklingduck on 9 Apr 2009 at 6:21 AM
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.
Report
Re: Compile a DOS C++ file in Windows Posted by AsmGuru62 on 10 Apr 2009 at 4:47 AM
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.
Report
Re: Compile a DOS C++ file in Windows Posted by darklingduck on 13 Apr 2009 at 10:41 AM
Hello,

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

cd C:\WATCOM
wmake -f C:\WATCOM\PPID_Update.mk -h -e -a C:\WATCOM\PPID_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<char,std::char_traits<char>,std::allocator<char>>'
Error(E42): Last command making (C:\WATCOM\PPID_update.obj) returned a bad status
Error(E02): Make execution terminated
Execution complete


Here is the source file:

// my first program in C++

#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
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;

}


Thanks



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.