What is use of #line directive in c programming language?

Answer:

It tells the compiler that next line of source code is at the line number which has been specified by constant in #line directive i.e. it transfer the program control to the line number which has been specified by #line directive.

e.g.

#line 15

void main()

{

int a=10;

a++;

clrscr();

a++;

#line 5

printf(“%d”,a);

getch();

}

 

If we will see its intermediate file then before the actual compilation the source code is expanded as:

 

In the very long c program for debugging purpose if we want to check the program after the line 300 by F7 key then we will write #line 20

Post a Comment