Title: EOF? ?? ??
121?. ??? ??? ?? ??
221-1 ???? ???? ??
- ????? ??
- ??, ??, ?? ????
- ???? ?? ??
- ???? ???? ?? ?? ??? ??
?? 21-1
321-1 ???? ???? ??
- ?? ???? ???
- ???? ?? ? ???? ?? ? ??
- ???? ???? ? ???? ?
?? ???? ?? ??? ??
stdin ?? ?? ??? ???
stdout ?? ?? ??? ???
stderr ?? ?? ??? ???
? 21-1
421-2 ?? ?? ???? ??
include ltstdio.hgt Int putchar(int c) Int fputc(int c, FILE stream)
??? ???? ?? EOF ??
include ltstdio.hgt Int getchar(void) Int fgetc(FILE stream)
??? ????? ??? ?? ???? ?? EOF ??
521-2 ?? ?? ???? ??
- EOF? ?? ??
- fgetc, getchar ??? ??? ?? ???? ?? ??
- End-Of-File? ????, ??? ?? ???? ?? ??
- (-1? ?? ???)
- ??? ?? Ctrl-Z? ??? EOF? ??
- ?? Ctrl_Z.c ??
- ?? ?? ? ??? ??? ???
- ??? ?? ??? ??? ?????? ?? ??? ??
621-2 ?? ?? ???? ??
/ Ctrl_Z.c/ include ltstdio.hgt int
main() char ch0 while(ch !
EOF) chgetchar()
putchar(ch) printf("program ??
\n") return 0
/ char_IO.c/ include ltstdio.hgt int
main() char ch0 while(ch !
'q') chgetchar()
putchar(ch) return 0
721-3 ??? ?? ???? ??
include ltstdio.hgt Int puts(const char s) Int fputs(const char s, FILE stream)
??? ???? ?? EOF ??
include ltstdio.hgt char gets(char s) char fgets(char s, int n, FILE stream)
??? ????? ??? ?? ???? ?? NULL ??? ??
821-3 ??? ?? ???? ??
/ puts_fputs.c/ include ltstdio.hgt int
main() fputs("fputs ??? ?? ??, ",
stdout) fputs("I Love Linux ", stdout)
fputs("\n", stdout) // ? ? ?? ?? ???.
puts("puts ??? ?? ??,") puts("I Love Linux
") return 0
/ fputs.c / include ltstdio.hgt int main()
char str10 fputs("???? ?? ???
", stdout) fgets(str, sizeof(str),
stdin) fputs("??? ??? ", stdout)
fputs(str, stdout) return 0
921-4 ?? ????? ??(Buffer)
- ??? ??? ???? ??? ??
- ??? ?? ???? ??? ???.
- ?? ??? ????.
- ??? ???, ??? ??...
?? 21-2
1021-4 ?? ????? ??(Buffer)
- ??? ??? ??? ?? fflush ??
- fflush ??? ???
- ?? fflush.c ??
include ltstdio.hgt int fflush(FILE stream)
?? ? 0, ?? ? EOF ??
?? 21-3
1121-4 ?? ????? ??(Buffer)
/ fflush.c / include ltstdio.hgt int
main(void) char perID7 // 6null??7
char name10 fputs("???? ? 6 ??? ?????
", stdout) fgets(perID, sizeof(perID),
stdin) fflush(stdin) // ?? ??? ???.
fputs("??? ?? ??? ", stdout) fgets(name,
sizeof(name), stdin) printf("???? ???
s\n", perID) printf("? ?
s\n", name) return 0
1221-5 ??? ?? ??
- ???? ??? ???? strlen ??
- ???? ???? ??
include ltstdio.hgt size_t strlen(const char s)
?? ? 0, ?? ? EOF ??
include ltstring.hgt  char strcpy(char dest, const char src) char strncpy(char dest, const char src, size_t n)
?? ? ??? ???? ??? ??
1321-5 ??? ?? ??
/ strlen.c / include ltstdio.hgt include
ltstring.hgt int main(void) char
str100 while(1) fgets(str,
sizeof(str), stdin) printf("???? ??
d \n", strlen(str)) return 0
1421-5 ??? ?? ??
include ltstring.hgt  char strcat(char dest, const char src) char strncat(char dest, const char src, size_t n)
?? ? ??? ???? ??? ??Â
?? 21-5
1521-5 ??? ?? ??
/ strcat.c / include ltstdio.hgt include
ltstring.hgt int main(void) char
str130"Your favorite language is " // null ??
?? 27??. char str210 fputs("What is
your favorite computer lanaguage ? ", stdout)
fgets(str2, sizeof(str2), stdin)
strcat(str1, str2) printf("??? ??? s
\n", str1) return 0
1621-5 ??? ?? ??
include ltstring.hgt  int strcmp(const char s1, const char s2) int strncmp(const char s1, const char s2, size_t n)
?? ? ??? ???? ??? ??Â
?? ? ??
0?? ? ?(??) str1? str2 ?? ? ??
0 str1? str2? ??? ?? ??
0?? ?? ?(??) str1? str2 ?? ?? ??
? 21-2
1721-5 ??? ?? ??
/ strcamp.c / include ltstdio.hgt include
ltstring.hgt char str1"ABC" char
str2"ABD" int main (void) int
result resultstrcmp(str1, str2)
if(resultgt0) puts("str1? str2?? ???
") else if(resultlt0) puts("str2?
str1?? ???") else puts("? ????
??? ????") return 0
1821-5 ??? ?? ??
- ???? ??? ???? ???
- ?????? ??? ???? ???
include ltstdlib.hgt  int atoi(char ptr) //
???? int? ???? ?? long atol(char ptr) // ????
long? ???? ?? double atof(char str) // ????
double? ???? ??
include ltctypes.hgt  int toupper(int c) // ????
???? int tolower(int c) // ???? ????