To use the things described here, #include the <cstdio> library.
Use
FILE* f = fopen(path, "r");to open file path for reading. If it is not possible to open the file, fopen will return NULL. |
When you are done reading the file, close it. Parameter f has type FILE*. |
This works just like scanf, but it reads from open file f, which must have type FILE*. |
This expression reads one character from open file f. It is like getchar, but reads from an open file. |
Write a complete program that takes two file names A and B from the command line. It should create a file called B and copy the entire contents of file A into file B. For example, if the executable program created from your C++ program is called copy, then command
copy myfile.txt myfile.cpymakes a copy of myfile.txt that is called myfile.cpy. Answer