1.

In C, What is the #line used for?

Answer»

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


Discussion

No Comment Found