• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Basic C Questions

Incinerator

Limp Gawd
Joined
Aug 31, 2005
Messages
252
ok I've taken C++ and Java courses before and I know how to compile them and everything but now I'm in a C class and the prof hasn't given us any information on how to compile the files or anything. I know its basically like C++ but the g++ compiler that I have used in the past for cpp files doesn't work for the C files I've written.

In the description it says something about makefile when talking about compiling the program kind of like it replaces the compiling...what is makefile? how do I use it? what does it do?

Thanks for the info
 
Well, a make file is sort of like a batch file that does the compiling for you, generally a program automatically generates this for you from a file that is autogenerated from something else and so on until you are completely confused.

If I were you I would just use gcc itself instead of any crazy make file business.
eg: gcc hw1.c hw2.c -o homework
 
I agree with Lord of Shadows. Let me guess the Comp Sci. department at your university wants you to use a freeware complier sorta like Bloodshed Dev C?
 
I'll definitely be looking into those links, thanks

also, one more question.
Is there a programming environment(?), like eclipse for Java, for C or C++?
 
Visual studio express is free, I think borland has a free student copy of their ide as well. As for *nix there's KDevelop and probably about 500 others. I normally just use a text editor and the compiler directly, ide's that indent for me drive me nuts.
 
I'll definitely be looking into those links, thanks

also, one more question.
Is there a programming environment(?), like eclipse for Java, for C or C++?

If you're hooked on eclipse, you can download the c++ developement tools for elipse. I have yet to use them but havn't heard anything bad about them.

http://www.eclipse.org/cdt/

Also, there's the Codeblocks IDE for c/c++:: http://www.codeblocks.org/
 
If I were you I would just use gcc itself instead of any crazy make file business.
eg: gcc hw1.c hw2.c -o homework

I agree, but maybe it would be good to add some switches to catch more errors?

Debug build (to debug with gdb.exe for example):
gcc -Wall -Wextra -ansi -pedantic -g file.c -o file

Release build:
gcc -Wall -Wextra -ansi -pedantic file.c -o file

Optimized release build:
gcc -Wall -Wextra -ansi -pedantic file.c -o file -O3 -s

Follow c99 (if allowed):
gcc -Wall -Wextra -pedantic -std=c99 file.c -o file -O3 -s

, so you can do like this:

Code:
#include <stdio.h>

int main() {
    for (size_t i = 0; i < 10; ++i) {
        printf("&#37;u\n", i);
    }
    int x = 10;
    printf("%u\n", x);
}
 
Back
Top