{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ch13 - 13.1 Y 2 cfw_w c 0 1 Y cfw 6 2 Y cfw 6 C Ccfw D xC...

Info iconThis preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
§ 13.1 Y2 ) !w 0 1 ˜!6;{+ © •μ ª*Y 2 ¨ ”¹ª ˜!6;{+ © •μ ª*Y C C{+ : ãD
Background image of page 2
ASCI I Ø ¹ª * ð= C Ø ”¹ª* 1 [email protected] @ ã ! H6 ANSI C 2 [email protected] @ @;ã ! ¸ ¹ª* ¸
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
§13.2 y - ) 3 y - ) X à Ì ( st di o. h typedef struct { int -fd; /* 3 */ int -cleft; /* */ int -mode; /* y- ) */ char * -nextc; /* y - ) */ char * -buff; /* y - ) */ } FILE; w 9
Background image of page 4
FILE *fp; f p FI LE ! f p ˜ ! 6 ; w 0; ) y § 13.3 h ) ! !
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
h fopen 3 FILE *fp; fp = fopen(“A1”,“r”); F ] fp 3 A1 13.1 p312 “r” n ) 3 “w” n ) 3 “rb” n ) “wb” n ) ……
Background image of page 6
f open “@ ; ”D if ( (fp = fopen(“file1”,”r”)) == NULL) { printf(“ cannot open this file \n”); exit (0); } 3 y - ( fclose 3 3 fclose ( fp ); 3 f p ” )
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
§13.4 y } 3 fputc 3 fgetc 3 putc 3 getc 3 fputc ( ch,fp); ch y } ”¹ª fp y} ”¹ª* ”¹ª EOF 3 -1 y 3 ch = fgetc ( fp ); fp F 6;{+ ch EOF(-1) y } )
Background image of page 8
feof (fp); fp 1 3 0 ; I]Cw n ) y g ch=fgetc(fp); while ( ! feof(fp) ) while (ch!=EOF) { ch=fgetc(fp); { putchar(ch); putchar(ch); ch=fgetc(fp); } }
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
[ 3 13.1 ] F ]C w 3l ) #” 3 33 #include “stdio.h” main() { FILE *fp; char ch,filename[10]; scanf(“%s”,filename); if((fp=fopen(filename,”w”))==NULL) { printf(“cannot open file\n”); exit(0); }
Background image of page 10
ch=getchar(); while(ch!=‘#’) { fputc(ch,fp);putchar(ch); ch=getchar(); } fclose(fp); } 3 3 file1.c 3* ) 3 computer and c# (* ) 3 computer and c (* ) 3
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
file1.c/ ) 3 C> type file.c computer and c [ 3 13.2] y g ) ! w 3 #include “stdio.h” main( ) { FILE *in, *out; char ch, infile[10], outfile[10]; printf(“ Enter the infile name: \n”); scanf(“ %s “,infile); printf(“Enter the outfile name: \n”); scanf(“ %s “,outfile);
Background image of page 12
if (( in=fopen(infile, “r”))==NULL) { printf (“cannot open infile\n”); exit(0); } if ((out=fopen(outfile, “w”))==NULL) { printf (“cannot open outfile\n”); exit(0); } while ( !feof(in)) fputc(fgetc(in),out); fclose (in); fclose(out); }
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Enter the infile name : file1.c ( 3 Enter
Background image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}