CSC209H5 Chapter Notes - Chapter 5: Gnu Compiler Collection, Scanf Format String, Standard Streams

27 views6 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) Taking a file that contains data, we are able to open and access the file in our c program using. File *fopen(const char *filename, const char *mode) filename - the file name mode - uses a string to indicate the mode. File opened for reading (a file must already exist) Creates a new file if file is not specified. Writes from beginning of the file (empties it if file contains something already) Writes from a specific section or line. To close a file, we do int fclose(file *stream) File *scores_file; scores_file = fopen( "top10. txt" , "r" ); if (scores_fill == null ) { fprintf(stderr, "error opening file \n" ); return 1 ; printf( "file opened!\n" ); if (fclose(scores_file) != 0 ) { fprintf(stderr, "fclosed failed\n" ); return 1 ; return 0 ; Reading from files char *fgets(char *s, int n, file *stream)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents