What is purpose of # in C

Status
Not open for further replies.

Ecko

Wandering In Tecno Land
We'll guyz I'm sill noob at C & this sem is just over
k just a small ques.
What is the purpose of #
I know its a pre-processor
but if someone can clearly xplain what is is
Xplain in as much lines as u can & i'm ready to read all
Ya I know many of u'll say C suc*s but u know its worth 100 marks here :D
 
the character # when used at the begening of a line tells the compiler to perform the action mentioned in the line before compilation of the code. Hence its called a pre processor. It does stuff to the code like including headder file functions, etc which need to be done BEFORE compiling.
 

dheeraj_kumar

Legen-wait for it-dary!
Any line with the # in the beginning is not compiled by the compiler. Thats because those lines are not part of the program, but rather, they contain information ABOUT the program. Thats not the exact way of putting it, but anyway. You can find more information on googling "Preprocessor Directives"
 
OP
Ecko

Ecko

Wandering In Tecno Land
Yaar preprocessor directives are the things after #
I wanna ask what # does
Any line with the # in the beginning is not compiled by the compiler.
What # do is tell compiler not to compile it or what ??
 
Dude dont get confused. # characters represents the beginning of a preprocessor directive. All preprocessor directives begin with a # and are also pronounced with it. A # directive is a special instruction to the compiler that it had to follow in the process of compiling. # character is used so that compiler can differentiate between a regular word and a preprocessor directive. # character signals the compiler start of a preprocessor directive. I hope its clear to u now :)
 

dheeraj_kumar

Legen-wait for it-dary!
See, first the code is checked for any lines beginning with #. If found, the preprocessor processes those lines. PREprocessor. Get it? PRE = BEFORE. So, before compilation, preprocessor is called. Then all the # lines are processed by it. Then all other lines are compiled by the compiler.
 

QwertyManiac

Commander in Chief
#, as a pre-processor in C is also used to define MACRO assembly directive blocks.

The MACRO and ENDM parts are generated into the compiled program via the use of #.
 
Status
Not open for further replies.
Top Bottom