On Sat, 2009-08-22 at 20:06 -0500, Elliander wrote: > I am not familiar with Ubuntu. I checked online for some C compilers > (It doesn't really matter to me if I am compiling in .exe or .deb as > long as I can study) but I couldn't find any in the style I am > familiar with. > .deb is an application package, not a program. Think of it as a .zip or .tar archive on steroids. Standard compilers (gcc, g++) are the GNU command line compilers. "man gcc" describes them pretty well. If you want to generate .exe files you need to use mingw rather than the standard Linux compilers, which are expecting their output to run as Linux processes. mingw (stands for Minimal Gcc for Windows) can run under Windows or under Linux as a cross compiler. It outputs .DLL and .EXE files rather than Linux libraries and executables. mingw is also a command line compiler. If you're compiling and linking more than one source file to make a program (and that's the usual Linux way of doing things) you also need to know about make and man. Make defines a dependency tree and uses it to recompile and relink a program in the fastest way possible. Its also used to tidy up the build directory and install programs and their documentation. If you're doing more than trivial programming you really need to use it because it will make like much simpler. Again "man make" tells all. Man, whatis and apropos are important too. All C library functions are documented in man pages. whatis and apropos are useful: they search the manpage collection. whatis lists all manpages whose name matches while apropos finds manpages with your search term in its title line. In this environment you can use the Gnome editor, gedit, but you may find it easier to use one of the text-only editors in a terminal window. vi (actually vim but it answers to vi) and emacs are the traditional choices. I like microemacs (aka me or uemacs), which is small, configurable, written in C and can load and edit several files at once. > As far as the terminal goes, I don't even know how to do that. I want > to learn more about programming in Unix based operating system but I > am used to windows. > You'll need some familiarity with bash, the standard Linux shell, so it may be worthwhile buying a copy of "Linux in a Nutshell" for reference. The O'Reilly books are generally very good. If prefer using an IDE like Visual Studio then try Eclipse. Its a general IDE that works with most languages (C, C++, Java, MicroFocus COBOL, PHP,...) and integrates with version control software such as CVS, Subversion and Git. I prefer the command line but ymmv. Here is your stuff back together with a makefile. This now compiles and runs when you type: make c7div on the command line. I've added comments about the changes. NOTE that all file names are lower case: this is the convention for C/C++ code and it matters because Linux commands are case sensitive: =============makefile==================== all: c7div clean: rm -rf *.o c7div c7div: c7div.o closeprog.o gcc c7div.o closeprog.o -o c7div c7div.o: c7div.c gcc -c c7div.c closeprog.o: closeprog.c closeprog.h gcc -c closeprog.c ========================================= Running "make" or "make all" compiles and links the program. Running "make clean" deletes the executable and the linkable .o files. Notice that 'all' has one dependency, the executable, which in turn depends on the two .o files, which are in turn dependent on the source files. Run 'make' again. Nothing happens because all dependencies are up to date. Now run: touch closeprog.c make Closeprog.o will be recompiled because its older than closeprog.c and this cascades up and causes c7div to be relinked ===================c7div.c======================= /* c7div.c Displays user's weekly pay */ #include <stdio.h> #include "closeprog.h" main() { float weekly, yearly; printf("What is your annual pay? "); // Prompt user scanf("%f", &yearly); weekly = yearly/52; // Computes the weekly printf("\n\nYour weekly pay is $%.2f", weekly); closeprog(); return 0; } ================================================= You wouldn't usually include a code fragment the way you did, so I changed the include file into a function definition, replaced the #include with a function call and added a prototype file for it. There's now an #include at the start of the file for the function prototype. ===================closeprog.h==================== /* closeprog.h - prototypes for closeprog() */ void closeprog(); ================================================== There's already a standard close() library function, so this function is called closeprog() to avoid confusion. ===================closeprog.c==================== /* closeprog() */ #include <stdio.h> void closeprog() { printf(" \n"); printf(" \n"); printf(" \n"); printf("_________________________________\n\n"); printf("End Of Program.\n\n"); } ================================================== Since this is a separate compilation unit, it must also include stdio.h and its a void function because it doesn't return anything. I hope this gives you a better idea of how the Linux compilation system works. Martin