I am new to the site, and new to C programming, and I wanted to know how to get started.
The mian question I have is, what compiler should I use to compile my code?
Thanks.
I am new to the site, and new to C programming, and I wanted to know how to get started.
The mian question I have is, what compiler should I use to compile my code?
Thanks.
When first getting started, it's better to test the waters with a free compiler than to spend money on a retail compiler. Two good ones for Windows are Bloodshed's Dev-C++ and Borland C++ 5.5. Dev-C++ is an IDE with the popular GCC compiler as the back-end, and Borland C++ 5.5 is a command line compiler. Both are free and high quality.
For Linux, you should already have GCC installed, so it's just a man away. For Unix, if it doesn't have GCC then it will probably have cc, which is the classic Unix C compiler.
My best code is written with the delete key.
Yes, I tried Dev-C++, but for some reason it doesn't compile.
I get this error:
"Unable to run program file"
and the compile log is this:
"Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Examples\Hello\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Examples\Hello\Makefile.win" all
Execution terminated"
Any idea what could be wrong? It isn't the code, I tried a sample script they included with Dev-c++ and got the same error.
Maybe the installation instructions should be re-read?
If you understand what you're doing, you're not learning anything.
There were not installation instructions. It just installed.
OK, I got it working. But I tried a sample code I whipped up
And a DOS window comes up for like .5 seconds and then disapears.Code:#include <stdio.h> main() { printf("Hello"); return 0; }
It sounds like you just installed the Dev-C++ front-end. There are two options if I recall correctly. One is just the IDE if you already have a compiler installed, and the other is the IDE with the GCC package. Which one of those did you choose on installation?
My best code is written with the delete key.
I got it working, I just added dev-cpp/bin to the compiler options and it compiles fine, but now
It comes up with a DOS window for like .5 seconds and then goes away with this code.
Code:#include <stdio.h> main() { printf("Hello"); return 0; }
>main()
This should be
Let's start the good habits early.Code:int main(void)
>printf("Hello");
You need a \n at the end of the format string because further output may look funny otherwise, and a newline is required to flush the stream so that you can see the output. This isn't terribly important on a Windows machine, but it's a good idea if you want portable code.
>It comes up with a DOS window for like .5 seconds and then goes away
The program is done. Because Dev-C++ opens a new command line window just for your program, when the program terminates, the window is destroyed. You can avoid this by a request for input. This causes a blocking read and leaves the window open until you hit [Enter]:
Code:#include <stdio.h> int main(void) { printf("Hello\n"); getchar(); return 0; }
My best code is written with the delete key.
Thanks for all of your help!
i use dev-cpp and i open up a seperate cmd (dos , or what used to be dos but now "windowsed") window, and then just compile it in dev-cpp but run it in the cmd window!
also from an earlier post, UNIX does not always have gcc installed. but all you need to do is put disc1 of your distro in and add the relevant packages!
hope that helps!
--CHriS
'rm -fr /bin/laden'
'kill all'
I've yet to see a UNIX installation without the cc compiler.
Microsoft is merely an illusion, albeit a very persistant one.
sure it comes with cc but one time it installed without the gcc compiler. ive never used cc and never been told to use it, thats all. isnt gcc the recommended compiler anyway? *hints at a debate amongst the C pr0s* hehe
--CHriS
'rm -fr /bin/laden'
'kill all'
i think gcc is the free implementation of cc. thats all.
I like LCC-win32. I comes as a complete development enviroment so it's easy to get started with. It's (almost) C99 compliant, and is well supported + actively developed.