Hi friends,
Please suggest me how to display the line number in C program. without using predefined macros, or windows library files.

Recommended Answers

All 4 Replies

In Pelles C it's under the Source pull down menu, then select "view line numbers".

Check around your IDE editor options, also. Not every IDE editor has this, for an option.

sorry.....i don't want to see line numbers in editior........i want the line number to be displayed on output..........like we get in assert funtion...

without using predefined macros

What is with you people asking a question and then immediately rejecting the best solution? What do you think the __LINE__ macro was designed for?

When you compile the source code, everything gets translated to machine code, and everything ends up being referenced by a memory address. In addition, the compiler will likely optimize your code, and will not maintain any 1 to 1 relation to the source code. The idea of a line number is lost by this point. It may be possible to use a debug file (such as a PDB file from VisualC++) to achieve this, but that would not be a trivial task.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.