I'm coding a program which is supposed to make an index of text files. I want to get a file from cmd and shows the output (index) in it. when I compile with turbo C, it creates an executable file that I can use it in cmd. but the problem is that when I run it in cmd it says that it's incompatible with windows 7. how I can fix it? notice that I have to use Turbo C compiler.
-
You'll have to run the program in DosBox, rather than running it from a standard cmd shell. The issue is that 16bit compatibility is not built in to the 64bit versions of windows. – Anya Shenanigans Dec 02 '13 at 10:33
-
it's quite too obvious. but due to the definition of the project, the input is taken from cmd as a file. so the question is till on. – Melika Barzegaran Dec 02 '13 at 10:35
-
You have two incompatible things here, a compiler producing 16-bit output and an OS without 16-bit support. One of them has to change. And for the record my personal opinion is that use of Turbo C is a cruel and unusual punishment. – r_ahlskog Dec 02 '13 at 10:44
-
1using such compilers helps the students to work with hardware details. actually it's a decision of a group of professors and they mean that. – Melika Barzegaran Dec 02 '13 at 10:55
-
I don't think producing programs that they can't run helps anyone, especially students. Changing compiler/OS (iirc 32bit windows still have support for 16bit dos programs) or using dosbox looks only possible options. – keltar Dec 02 '13 at 11:20
-
You won't get anywhere near the hardware running on 64 bit Windows. You should just install DOS or Windows 3.1 since you want to use 16 bit code. Why don't you do that? – David Heffernan Dec 02 '13 at 11:33
2 Answers
The 64bit version of Windows will not run 16bit apps without third party intervention. You're building 16 bit applications with Turbo C.
The solutions are:
- Run within dosbox
- Run From a 32bit Virtual Machine
Running the program from dosbox is trivial. Make sure that the dosbox.exe
is in the path. Launch dosbox using the current directory:
dosbox .
Then run the program from the launched dosbox (it looks like a cmd shell).
For a virtual machine you can make the drive that you build the binaries a shared folder with the VM and run them from a cmd prompt within the virtual machine.
As long as the input file is accessible from the environment within which you're running, then you should be able to invoke the command with the filename as a parameter.
While I appreciate that your lecturer is forcing you to use an obsolete compiler in an environment that does not support it properly, you will have to jump through hoops yourself to achieve the solution.
You should also point your professor to the Microsoft Website, where express editions of their compilers are available which work perfectly well on newer versions of windows, are free, support newer versions of the C and C++ specification and will more likely help students if they are actually trying to use C and C++ in the real world.

- 91,618
- 3
- 107
- 122
-
Running program in dosbox is exercise by itself. Furthermore, it emulates correct DOS environment (while `cmd` does not). +1 – keltar Dec 02 '13 at 11:28
I think the problem is with the compiler - try getting a newer version, compatible with win 7.

- 4,843
- 3
- 27
- 44
-
turbo c doesn't have newer versions. but some people with DosBox has made it compatible so that turboc can be used in vista/7/8 though they don't work efficiently. so the question is still on. – Melika Barzegaran Dec 02 '13 at 10:23
-
-
I think you are going to get unwanted behavior no matter which version of the compiler you get since it does not support win 7. I would install Winxp, or whichever os it worked on last, on a Virtual Machine. It'll save you the headache of trial and error. – Pandrei Dec 02 '13 at 11:32