ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
One possible cause may be that you are running a version of the executable that was compiled without the comment in place.
Another, more likely, cause may be that the program actually crashes on the "close(f)" or "close(g)" calls. One would expect the program to print another line saying "8", because there is another printf("\n8") before the close() calls. But my guess is that this does not happen due to compiler optimization. It seems to me that two identical statements after eachother ( printf"\n8" skipping the comment lines of course) is an ideal opportunity for the compiler to do some optimization tricks. Optimization is a known source for confusion when debugging, or when something goes wrong.
Do you compile with gcc's "-O.." option?
If so, try without it.
To explain acids's post. He's right - it crashes on fclose. When printfs are used (not only, in fact) everything you print on the screen is first kept in a buffer. It's dsplayed when '\n' or a similar thing happens. So