1. The output from source code and showed output are different:
- in source code function printf("Open file: ..... is before filename reading with gets(file).
- showed output hasn't a line with input a filename - gets() is a function with echo and character input is displaying on the screen.
2. In source code has an error with printf - this printf doesn't output filename:
- no %s - need to be printf("Open file: %s", ...)
- %s need a parameter of type *char but the current parameter is a **char (&file is a pointer to parameter 'file' and 'file' is a *char). As a result we will have output a sequence of symbols, started from address of 'file' variable in memory and nobody can know the length of sequence (somewhere program will find a zero-byte and will stop).
Example don't workVess Georg February 12, 2013 at 7:09 PM
1. The output from source code and showed output are different: - in source code function printf("Open file: ..... is before filename reading with gets(file). - showed output hasn't a line with input a filename - gets() is a function with echo and character input is displaying on the screen. 2. In source code has an error with printf - this printf doesn't output filename: - no %s - need to be printf("Open file: %s", ...) - %s need a parameter of type *char but the current parameter is a **char (&file is a pointer to parameter 'file' and 'file' is a *char). As a result we will have output a sequence of symbols, started from address of 'file' variable in memory and nobody can know the length of sequence (somewhere program will find a zero-byte and will stop).
c progammingcharmin January 28, 2012 at 11:10 PM
thank u for giving me the source code
FileRead.cPawan Kumar January 31, 2012 at 5:51 PM
This above file read code doesn't work.Please help me to correct it.
your postAnubhab91 February 20, 2012 at 7:47 PM
Thank you. Your post was useful.
c language programmingfalco September 1, 2012 at 1:23 PM
how can I write a programme that will create a file that can store CV 's.
help meali December 30, 2012 at 2:52 PM
if I want to make a map for a C program how I can make pages for my program map.please,help me how I can go to next page of map.very very thanks:D
Post your Comment