Chap. 1 : Unit 6 : Sample C Program : Part 3

This video explains how to save the file in proper folder and how to compile the program in DOS environment. 

Now save the file. This code is called as source code. While saving the program make sure that it is saved in the appropriate folder of your own. Now it is the time to compile the source code to convert it into machine code. Under the DOS environment menu has provide the compile option…when you compile pop up window will give you information like name of file getting compiled, number of lines being compiled, number of warnings and number of errors etc. in the Linux environment gcc is the command which has to be given at the command prompt followed by file name followed by executable file name.

Dear friends, it is common misconception that compiler is meant for finding errors. But its primary task is to convert the source code into machine level language or object code. During this process if it encounters any hurdle due to syntax irregularities then it throws errors and warning. Also errors and warning are given as a hint for programmer to rectify and correct. So line number for error and warning should not be taken literally.

Suppose you have declared a variable but not used in the program, it may give warning message or if you forget to write return type of main function it may give you warning or error message. For example under the DOS environment if you forget to write void before main it will give you warning message as function should return a value…

But don’t forget that warning is never for ignoring purpose. In C also you should never ignore warning no matter how trivial those are…

Compile time errors may be due to many reasons like you have used variable without declaration, or you forget to write closing curly brace of main function or forget to put semicolon to terminate the statement and so on….which may create trouble for you…

But never ever, I mean never ever lose the patience, no matter how many errors or warnings are encountered during program development. Because errors and warning will teach you the programming and indicates that you are learning programming on the right track. After all to err is the human… know?

Once all errors and warnings are identified and rectified, you are ready for executing the program…however one can encounter errors while execution of the program which generally is called as run time errors. These are generally occurred due to either logical errors in the program or due to memory leak due to pointers. We will study these as and when we come across such topics.

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register free (log in ) on Register / Login


Leave a Reply