FILE1 - fclose(stream); /* close file */ /* open a file for...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <stdio.h> # struct mystruct { int i,j; char ch; }; } int main(void) { FILE *stream; struct mystruct s; int i = 100; char c = 'C'; float f = 1.234; if ((stream = fopen("TEST.txt", "wb")) == NULL) /* open file TEST.$$$ */ { fprintf(stderr, "Cannot open output file.\n"); return 1; } s.i = 100; s.j=101; s.ch = 'A'; fwrite(&s, sizeof(s), 1, stream); /* write struct s to file */
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fclose(stream); /* close file */ /* open a file for update */ stream = fopen("DUMMY.txt", "w+"); s /* write some data to the file */ fprintf(stream, "%d %c %f", i, c, f); f /* close the file */ fclose(stream); f return 0; }...
View Full Document

This note was uploaded on 10/25/2010 for the course CMPN SEM1 taught by Professor Thakur during the Fall '06 term at University of Mumbai.

Ask a homework question - tutors are online