diff --git a/2207/C语言同步练习源码/8-文件-3.c b/2207/C语言同步练习源码/8-文件-3.c new file mode 100644 index 0000000..0f1d3d3 --- /dev/null +++ b/2207/C语言同步练习源码/8-文件-3.c @@ -0,0 +1,20 @@ +#include + +int main(){ + char str[100]; + char *p = str; + FILE *fp; + fp = fopen("test.dat", "w"); + gets(str); + + while(*p != '\0'){ + if(*p >= 'a' && *p <= 'z'){ + *p-=32; + } + p++; + } + fputs(str, fp); + fclose(fp); + return 0; +} + diff --git a/2207/C语言同步练习源码/test.dat b/2207/C语言同步练习源码/test.dat new file mode 100644 index 0000000..a815426 --- /dev/null +++ b/2207/C语言同步练习源码/test.dat @@ -0,0 +1 @@ +ADFADFAAAFDAFDSFSDF \ No newline at end of file diff --git a/2207/C语言同步练习答案.md b/2207/C语言同步练习答案.md index 56e2c34..e5c0a04 100644 --- a/2207/C语言同步练习答案.md +++ b/2207/C语言同步练习答案.md @@ -1089,5 +1089,28 @@ int main(){ ![image-20250227231516025](https://yp.smallkun.cn/markdown/image-20250227231516025.png!compress) +```c +#include + +int main(){ + char str[100]; + char *p = str; + FILE *fp; + fp = fopen("test.dat", "w"); + gets(str); + + while(*p != '\0'){ + if(*p >= 'a' && *p <= 'z'){ + *p-=32; + } + p++; + } + fputs(str, fp); + fclose(fp); + return 0; +} + +``` +