Files
BasicsOfComputerSoftwareEng…/POP/14/Exercise02.c
2023-02-21 10:56:54 +08:00

31 lines
529 B
C

#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;
}