修改文件结构。
This commit is contained in:
31
POP/14/Exercise02.c
Normal file
31
POP/14/Exercise02.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
|
||||
char toUpper(char input) {
|
||||
if (input >= 'a') {
|
||||
return input - 'a' + 'A';
|
||||
}
|
||||
else {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
char ch;
|
||||
FILE* fl;
|
||||
fl = fopen("upper.txt", "w+");
|
||||
while (1) {
|
||||
ch = getchar();
|
||||
if (ch == '#') {
|
||||
break;
|
||||
}
|
||||
fprintf(fl, "%c", toUpper(ch));
|
||||
}
|
||||
fflush(fl);
|
||||
// fclose(fl);
|
||||
// fl = fopen("upper.txt", "r");
|
||||
rewind(fl);
|
||||
while(!feof(fl)) {
|
||||
putchar(fgetc(fl));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user