2_Questions_7-1

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

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 DocumentRight 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
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.

This note was uploaded on 09/02/2011 for the course CIS 15BG taught by Professor Staff during the Spring '10 term at DeAnza College.

Page1 / 4

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

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online