Q:

The #line directive Example in C | C preprocessor programs

belongs to collection: C Preprocessors Programs

0

The #line directive Example in C | C preprocessor programs

The #line is a preprocessor directive in C programming language; it is used to reset the line number in the code. We can reset line number from any line in the code.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Example:

#include <stdio.h>	/*line 1*/
/*line 2*/
int main(){	/*line 3*/
/*line 4*/
	printf("Hello world\n");	/*line 5*/
	//print current line	/*line 6*/
	printf("Line: %d\n",__LINE__);	/*line 7*/
	//reset the line number by 36	/*line 8*/
	#line 36	/*reseting*/
	//print current line	/*line 36*/
	printf("Line: %d\n",__LINE__);	/*line 37*/
	printf("Bye bye!!!\n");	/*line 39*/
/*line 40*/
	return 0;	/*line 41*/
}	/*line 42*/

Output

    Hello world
    Line: 7
    Line: 37
    Bye bye!!!

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Define Macros for YES and NO constants using #defi... >>
<< Print the current function name by using __func__ ...