Print Source File Name C Program

By | October 13, 2016

Learn How To Find The Source File Name of the C Program and Print it in C Programming. To print the source file name, you need to use Pointers and Command Line Arguments in C Programming.

Must Read: C Program To Print Map of India

C Program To Find Source Code Object File Name

#include<stdio.h>

int main(int argc, char *argv[])
{
      char *ptr = argv[0];
      printf("\nName of the Source Code File:\t%s\n", ptr);
      return 0;
}

Output

C Program To Print Source File Name using Pointer and Command Line Arguments

If you have any compilation errors or doubts in this C Program To Find and Print Source Code File Name using Pointers, let us know about it in the comment section below.

Let's Discuss