Saturday, 18 December 2010

Algorithm for To display the contents of a file

Description:

The program will read the contents of a given file and displays on the screen

Algorithm:


1. Start

2. Enter the name of the file to read

3. Open the given file in read mode using fopen()

4. If we get a null pointer the file does not exist, we can exit

5. If the file opens without any error

6. Read the contents of the file character wise

7. Print each character as you read

8. Once you reach the end of file

9. Close the file using fclose()

10. stop


Output:

Enter the name of the file you want to see
Red

The contents of file red are:
Hello this a simple file create to test the file funmnctions of c
Fopen is used to open the file .fclose is used to close file.

Enter the name of the file you want to see
Bill

The file doesn’t exist

Conclusion:  The program is error free



Algorithm


No comments:

Post a Comment