print the name of a file c

To print the name of a file in C, you can use the printf function to display the name as a string. Here's an example code snippet that demonstrates this:

#include <stdio.h>

int main() {
    char filename[] = "example.txt";
    printf("The name of the file is: %s\n", filename);
    return 0;
}

Explanation: 1. The #include <stdio.h> line includes the necessary header file for input/output operations in C. 2. The main function is the entry point of the program. 3. We declare a character array filename and initialize it with the name of the file we want to print. 4. The printf function is used to display the name of the file. The %s format specifier is used to print a string, and the filename variable is passed as an argument. 5. The \n is a newline character, which adds a line break after printing the file name. 6. Finally, the return 0 statement indicates that the program has executed successfully.

When you run this code, it will output:

The name of the file is: example.txt

Please note that you can replace "example.txt" with the actual name of the file you want to print.

I hope this helps! Let me know if you have any further questions.