Oh, yes, a C compiler is a very definite must. As for running the program, compiling it produces an executable file, so you just run that executable at the command line.

Before we can recommend a free C compiler, we need to know what OS you are running.

If Linux, then you should already have the GNU C compiler installed, gcc. If not, then it should be on your distro CDs, in which case you will have to install it and its development libraries. If it is not on the distro CD (I encountered that with ManDrake 7.2; gcc was only on the more expensive Power-User distro), then you will need to download it.

If you are running Mac OS X, then you are actually running FreeBSD. I've not worked with FreeBSD, but I assume that it comes with a C compiler -- I just don't know what it would be called (cc?). You would have to do all this from the terminal, I'm sure.

Safest bet is that you are running Windows, in which case you have a few options available.

If you feel more comfortable with a brand name, Borland offers version 5.5 (Aug 2000) of their C++ compiler and command-line tools for free download. Go to http://www.borland.com/products/down..._cbuilder.html . I found their on-line registration a bit of a hassle. In addition, you'll get the 32-bit version of grep and a few other command-line utilities. Note that you will also be able to compile both C and C++ programs with this compiler.

Another free C compiler is lcc-win32 at http://www.cs.virginia.edu/~lcc-win32/ . Please note that this is C only, not C++. Even if you don't use lcc-win32, a visit to their site would still be worth your while for the documentation and C tutorial that they offer.

Another free C/C++ development environment that is widely recommended on this forum (that's where I learned about it) is Dev-C++ by Bloodshed Software at http://www.bloodshed.net/ . It's a fairly complete IDE that uses the MinGW port of gcc to Windows.

If all you want is the compiler itself, then you can download MinGW's gcc directly from their site at http://www.mingw.org/ .

Well, then, that boils it down to Borland, lcc-win32, or Dev-C++. Pick one and perform the installation.

Borland will be strictly command-line, AKA "DOS" AKA "Command Prompt". You know, that icon that Microsoft keeps burying deeper and deeper trying to hide it from us. You would most likely need to create and use a makefile for it, which adds an extra layer of complexity. So Borland might not be your best bet.

lcc-win32 and Dev-C++ both provide you with a GUI integrated development environment (IDE), which gives you an editor, dialogs for setting up your projects, allows you to run the compiler from within the IDE, displays error messages, and (usually) takes you straight to the line of code that caused the error. They also usually include a debugger.

Dev-C++ appears to be used more widely here than lcc-win32, so more help should be available with it. Also, when you want to move on to C++, you'll already have a compiler and IDE that you're familiar with (remember, lcc only does C). And if you want to do it all from the command-line instead (my personal choice, but then I'm an old DOS'er from before Windows v1.0 and a Linux neophyte), then I can step you through that for Dev-C++.

Dev-C++'s stable version is Version 4 and its Version 5 is in beta. There have been reports here of v5 having problems under XP, whereas others report that they use v4 under XP with no problems at all. So if you go with Dev-C++, I would recommend that you start out with version 4.

Once you download the software, simply follow the instructions on the web page and/or in the readme file.

Originally posted by jayshah11 I did download the version 4 and wrote a small C program but while compiling i am getting an error that

instalation problem, cannot exec 'gcc': No such directory

can't exec 'gcc': No such file or directory

Guide me on this one. What can be wrong?

It looks like Dev-C++ cannot find gcc, which doesn't make any sense to me. gcc should have been installed and Dev-C++ should know where to find it.

Now, I assume that you are doing the compile from within the IDE -- but of course, DOS would report "Bad command or file name", unless they changed that for XP.

Dev-C++ should have created a directory off the root called dev-c++ . In that directory there should be a subdirectory called bin . Look inside that directory (\dev-c++\bin) and verify that the file, gcc.exe, is there. If it is not, then somehow the installation did not work and you would need to reaccomplish it.

BTW, if you were trying to run gcc from the command line, then you will need to add \dev-c++\bin with its drive letter to the search path; eg,
PATH=C:\Dev-C++\bin;%PATH%
You should not need to do this if you are compiling within Dev-C++.

Originally posted by jayshah11
Can i use Visual C++ to write my C programs and run them?

You had originally specified "free", so I did not mention Visual C++ -- Bill Gates was one of the first ones to strongly advocate non-free software.

VC++ is strongly oriented towards GUI apps, but you can create console apps with it. When you do a File | New to call up the New dialog, under the Projects tab select "Win32 Console Application", give it a project name and location, and click OK. Select "An empty project" and click on Finish and then OK on the verification dialog. Now create a new text file, save it as a .C file, and add it to the project (Project | Add to Project | Files). When you compile the program, the .exe file will be in the debug subdirectory -- I normally open a DOS window and cd to that subdirectory to run the program.

That's how I used to do all my network programs until I started using Dev-C++'s gcc -- from the command line, of course.