print name of file argv c

The following C code snippet demonstrates how to print the name of a file using the argv[] parameter:

#include <stdio.h>

int main(int argc, char *argv[]) {
    printf("File name: %s\n", argv[0]);
    return 0;
}

Explanation: - The #include <stdio.h> statement is used to include the standard input-output library, which provides functions like printf() and scanf(). - The main() function is the entry point of the program. It takes two parameters: argc and argv. The argc parameter represents the number of command-line arguments passed to the program, and argv is an array of character pointers that hold the command-line arguments. - The printf() function is used to print the file name. The format specifier %s is used to print a string. argv[0] represents the first element of the argv array, which is the name of the program itself. - Finally, the return 0; statement is used to indicate successful termination of the program.