Yesterday, I encountered a problem when I went to the public comment interview. The interviewer asked: please writeProgramThe program function is able to output the program file from the beginning to the end. If you can write it out in five minutes, we will commit it!
For such an interview question, I thought about it and wrote it for your reference.
Source program:
# Include <stdio. h> # include <stdlib. h> int main () {// defines the file stream pointer file * file = fopen ("Main. C "," R "); // determine whether the file stream is successfully opened before reading. If (file = NULL) {// output error message perror (" Main. C "); Return exit_failure;} int ch; // read and output while (CH = fgetc (File) cyclically ))! = EOF) {fputc (CH, stdout) ;}fclose (File); Return 0 ;}
The program running result is:
Although the program is simple, if you can write it quickly and accurately, the offer belongs to you!