In this program, we will print the line number in the source code using __LINE__ macro on the console screen.
Here, we will use three macros, __LINE__, __FUNCTION__, and __FILE__.
The source code to print the line number in the source code with filename and function name is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
// C program to print the line number in source code
// with filename and function name
printf("Line Number %s->%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
Line Number main.c->main:8
In the main() function, we printed the line number with filename and function name using __LINE__, __FILE__, and __FUNCTION__ macros on the console screen.
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.