Skip to Main Content
Programming and Data Structures
book

Programming and Data Structures

by Ashok Kamthane
August 2009
Intermediate to advanced content levelIntermediate to advanced
604 pages
21h 39m
English
Pearson India
Content preview from Programming and Data Structures
Files 421
fcloseffp);
printf C\n Contents read
fp*fopen("data.txt""r");
while Ofeoftfp))
printf <u%t",getc(fp));
J
rMrrpi nr*
K w AAmW At
Write data fe to stop press V: ABCDEFGHIJK.
Contents rtstd: ABCDEFGHIJK.
Explanation In the above program the file named "d a t a . t x t " is opened in written mode. The
characters are read from the keyboard and stored in variable 1 c '. Using f putc () the characters
are written to a file until ' . 9 (Dot) is pressed.
The same file is closed and then it is re-opened in read mode. On reopening of the file character
pointer sets to the beginning of the file. The contents of the file will be displayed on t
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Data Structures and Algorithms

Learning Data Structures and Algorithms

Rod Stephens
Data Structures and Algorithms in C++, Second Edition

Data Structures and Algorithms in C++, Second Edition

Michael T. Goodrich, Roberto Tamassia, David M. Mount

Publisher Resources

ISBN: 9789332506343