Special welcome gift. Get 50% off your first courses with code “AS50”. Find out more!

HomeInterviewC Q/A In C, What is the #line used for?
course 6

 In C, What is the #line used for?

In C, #line is used as a preprocessor to re-set the line number in the code, which takes a parameter as line number. Here is an example for the same.

#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*/

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

Categories

ads sidebar 1

You May Also Like

Oracle has several modes for shutting down the database: In normal mode, the database is shut down by default. It...
Materialized views are items that contain condensed sets of data from base tables that have been summarized, clustered, or aggregated. They...
Every database in Oracle has a tablespace called SYSTEM, which is generated automatically when the database is created. It also...