The ultimate C printf debug line

This post was written by eli on November 9, 2019
Posted Under: Software

The simplest way to add printf statements that say “I was here”:

printf("File %s, Line %d\n", __FILE__, __LINE__);

The output is then simply e.g.

File bulktest.c, Line 120

So make sure everything is committed into the git repo, and bombard the code with these lines. Compile and run.

The is also __func__ (lowercase, or it doesn’t work) which turns into the name of the current function. Also useful.

Add a Comment

required, use real name
required, will not be published
optional, your blog address