{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2_Questions_7-1 - CIS 15AG Questions Chapter 7 Text files 1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 15AG Questions Chapter 7: Text files 1. Write a function named myFileOpen that opens "MOVIES.TXT" in "w" mode; if there is a file with this name the function displays "Do you want to overwrite "MOVIES.TXT"? [Y/N]: " and gets the user's input. If the user disagrees, NULL should be returned, otherwise the file pointer; also if fopen() fails to open the file in "w" mode, NULL should be returned (do not use exit() at all). #include <stdio.h> #include <ctype.h> // HINT: use toupper() #define FLUSH while ( getchar() != '\n' ) FILE * myFileOpen( void ); int main ( void ) { FILE * fpMovies; fpMovies = myFileOpen(); if ( fpMovies != NULL ) printf( "\"MOVIES.TXT\" – successfully opened\n" ); else printf( "\"MOVIES.TXT\" - not available\n" ); return 0; } FILE * myFileOpen( void ) { 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CIS 15AG Questions Chapter 7: Text files 2. Write a program that reads movies from "MOVIES.TXT" and displays all movies that begin with the letter 'T'. The file is not alphabetized. Assume the file is valid: one movie per line (title and year), and each line has a '\n', including the last one.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}