|
|||
|
The function fopen returns a pointer to the file if it's successful at finding and opening the file specified. But what if the file doesn't exist? Take a look at this reference page for fopen to see what fopen returns in those cases. Armed with what you learned from the above reference page, how would you modify integ.c or monte.c so that they exit gracefully if the files they attempt to open don't exist? Give it a try, and talk to your classmates to find out if you came up with the same solution. If you have the time, try to take a look at the HowStuffWorks.com tutorial on files. Finally, you can do much more with files than simply open them and read in a number or a string; take a look at the file access functions within the stdio.h library and this reference page on file read functions to learn more about reading from and writing to files. Continue on to the Module on Arrays -> |
||
Website by Joshua Bleier |