Skip to content

Instantly share code, notes, and snippets.

@Rajssss
Created December 29, 2021 07:50
Show Gist options
  • Save Rajssss/a7aab411bdc09f1cd3553b578bc64898 to your computer and use it in GitHub Desktop.
Save Rajssss/a7aab411bdc09f1cd3553b578bc64898 to your computer and use it in GitHub Desktop.
printf print line no and file name
#include <stdio.h>
/* redefine printf for the rest of file. */
#define printf(...) \
do { \
printf("%s: %d:\t", __FILE__, __LINE__);\
printf(__VA_ARGS__);\
} while (0)
/* after this point, each call to printf will be replaced by two. */
int main(void)
{
printf("Hello\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment