How to complie c program using DOS? Is there some DOS C complier?
How to complie c program using DOS? Is there some DOS C complier?
If you mean "I want to type in a command from the pretty command prompt window and have it compile" then every compiler has such a thing, even Visual Studio. (What the command is depends upon the compiler.)
If you mean "Does a compiler come with Windows", then no.
If you mean "I have a pre-1995 computer that's actually running DOS and I want a compiler", then there are such things but I don't know what they are.
You'll want Turbo C/C++ version 1.01, from Borland. It's from from their legacy site. I would avoid Turbo C version 2.0, which preceded it, however.
Be sure to list all your variables before making assignments to any of them, however:
Stuff like this will make the Turbo C compiler cough an error that isn't easy to figure out.Code:int i, j; i = 0; char ch;
Turbo C/C++ runs in a console (DOS) window in Windows2K, or XP, at least.
It's more likely that you just want to compile your program from the command prompt, I think.
In that case, assuming you have Dev-C++, try this:
If Dev-C++ put its Bin folder in the path, that should work. (Assuming "program.c" is in the current directory.)Code:gcc program.c -o program.exe
I don't know how you would do this with, say, MSVC. You could search for it, or wait for Elysia to tell you.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I dunno. It doesn't look too hard. http://msdn.microsoft.com/en-us/library/610ecb4h.aspxYou don't want to compile with MSVC from the command prompt. It's difficult and error prone.
You could always use make (or whatever MS calls it) if the commands to type are long. I highly recommend make anyway, even if you're not using the command line to compile your program. (Your IDE might be using make in the background without you even realizing it.)
You really shouldn't use Turbo C unless you really are using a really old DOS system, however. It has a lot of shortcomings that are easily avoided by using more modern compilers.
Incidentally, DJGPP (which robwhit linked to) is a port of GCC to DOS, so you can use my Dev-C++ command with it as well.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Well, if you feel like taking a stab at it, this looks very comprehensive: http://www.functionx.com/visualc/com...ne/cmdline.htm
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
LOL.Code:# Type the following in the empty file: #include <iostream> using namespace std; int main() { cout << "\nC++ is Fun!!!\n"; return 0; } # Close the project and accept to save each file. # On the command prompt, change to the directory in which the file was saved. For me, that would be C:\Programs\MSVC\Exercise1 # To build the project, type CL main.cpp and press Enter (CL stands for Compile and Link) You should receive a series of lines: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>CD Program Files\Microsoft Visual Studio\VC98\Bin C:\Program Files\Microsoft Visual Studio\VC98\Bin>VCVARS32 Setting environment for using Microsoft Visual C++ tools. C:\Program Files\Microsoft Visual Studio\VC98\Bin>CD\ C:\>CD Programs\MSVC\Exercise1 C:\Programs\MSVC\Exercise1>CL main.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. main.cpp C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\istream(547) : warning C4530: C++ exception ha ndler used, but unwind semantics are not enabled. Specify -GX C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\ostream(234) : warning C4530: C++ exception ha ndler used, but unwind semantics are not enabled. Specify -GX C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\ostream(229) : while compiling class-t emplate member function 'class std::basic_ostream<char,struct std::char_traits<c har> > &__thiscall std::basic_ostream<char,struct std::char_traits<char> >::put( char)' C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\ostream(234) : warning C4530: C++ exception ha ndler used, but unwind semantics are not enabled. Specify -GX C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\ostream(229) : while compiling class-t emplate member function 'class std::basic_ostream<unsigned short,struct std::cha r_traits<unsigned short> > &__thiscall std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >::put(unsigned short)' C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\istream(46) : warning C4530: C++ exception han dler used, but unwind semantics are not enabled. Specify -GX C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\istream(41) : while compiling class-te mplate member function 'bool __thiscall std::basic_istream<char,struct std::char _traits<char> >::ipfx(bool)' C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\istream(46) : warning C4530: C++ exception han dler used, but unwind semantics are not enabled. Specify -GX C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\istream(41) : while compiling class-te mplate member function 'bool __thiscall std::basic_istream<unsigned short,struct std::char_traits<unsigned short> >::ipfx(bool)' C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\xstring(525) : warning C4530: C++ exception ha ndler used, but unwind semantics are not enabled. Specify -GX C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\xstring(521) : while compiling class-t emplate member function 'void __thiscall std::basic_string<char,struct std::char _traits<char>,class std::allocator<char> >::_Copy(unsigned int)' C:\PROGRA~1\MIAF9D~1\VC98\INCLUDE\ostream(296) : warning C4530: C++ exception ha ndler used, but unwind semantics are not enabled. Specify -GX main.cpp(6) : see reference to function template instantiation 'class st d::basic_ostream<char,struct std::char_traits<char> > &__cdecl std::operator <<( class std::basic_ostream<char,struct std::char_traits<char> > &,const char *)' b eing compiled Microsoft (R) Incremental Linker Version 6.00.8447 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /out:main.exe main.obj C:\Programs\MSVC\Exercise1>
That's a direct quote from the tutorial. It's not a "borked EXE". Apparently, it still runs.
And anyway, it's being pretty clear, isn't it? Specify -GX on the command line, because you're using exceptions.
I can't believe it. I'm defending MSVC.
(I do agree, though; the tutorial probably isn't very good if that's what it's saying . . . .)
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Of course it runs. But does it run according to specs?
And who says it isn't a walking time bomb?
Have you looked at the command the GUI creates? It's far more complicated and advanced.
You should ALWAYS use that, or disable exceptions altogether. Non-stack unwinding when using exceptions isn't part of the C++ spec, is it?And anyway, it's being pretty clear, isn't it? Specify -GX on the command line, because you're using exceptions.
Cheers. Here's where we do agree.(I do agree, though; the tutorial probably isn't very good if that's what it's saying . . . .)
My VC doesn't say that at all. It says
C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
I would think that if that's how they compiled the libraries (all we wanna do is std::cout, is that so much to ask?) that would be the default.
Edit: Man is the OP going to be surprised by this thread.
Perhaps it's not the default because exception handling is presumably disabled for C programs?
(But then why wouldn't it be the default for source code with a .cpp extension? . . . .)
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.