Originally posted by: BingBongWongFooey
Originally posted by: AEB
i have used this compiler a little and seems like you are doing it ok. whereas im not a C buff in C++ yu wouldnt write
int main(void){ it would be like int main(){
int main() is fine, although I don't know much about the difference.
C was an interestingly different language before it was standardized by ANSI. It had a variety of implicit defaults, partly because of the lack of function prototypes.
In C, if the function parameter list is empty, that actually means you can call the function with any or no arguments at all (this is different from varargs). Any arguments would be ignored since you couldn't identify them. So that's why C's function(void) is equivalent to C++'s function(). Similarly, functions were assumed to return int unless specified otherwise.
AFAIK, ANSI C tried to remain as K&R C (1st Edition) compatible as possible, but I don't know how common pre-ANSI C code would fare with an ANSI C compiler.
To use gdb, first compile with debugging symbols by passing the
-g flag to gcc. To perform an actual debug session, you would invoke:
gdb a.out
gdb is a CLI tool so you'll need to consult a manual to figure anything out. If you've used a symbolic debugger before, then
you can get basic help from within gdb.
Offhand, I don't see anything wrong with the hello program shown. Nor do I have a RH Linux 8.0 system to test on. Wait a second, since you replied with an update, I think you should take a close look at the
beginning of the shell prompt after running a.out. It probably looks like
hi~yohhan/: $. Or whatever a bash prompt looks like, since I'm using Windows right now. In other words, "hi" is printed before the following shell prompt. '\n' would just add a newline to make things obvious.
Funny that AEB finds it appropriate to give C++ APIs as a solution to a C question.