热门

最新

红包

立Flag

投票

同城

我的

发布
xiaomanonge
xiaomanonge
5 年前
truexiaomanonge

老师要求编写一个将小写转换为大写并输入指定文件中的文件,源代码如下,不管我用什么地址这个打开的操作都会出错,希望能有大神解决一下小弟的困惑
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE* fp;
int i=0;
char c[10],ch;
while((c[i++]=getchar())!='\n')
for(i=0;i<10;i++)
if(c[i]>='a'&&c[i]<='z')
c[i]-=32;
if((fp=fopen("test.txt","w+"))==NULL)
{
printf("cannot open the file\n");
getchar();
exit(0);
}
for(i=0;i<10;i++)
fprintf(fp,"%c",c[i]);
fclose(fp);
if((fp=fopen("C:\\UU\\text.txt","r"))==NULL)
{
printf("cannot open the file\n");
getchar();
exit(0);
}
while((ch=fgetc(fp))!=EOF)

CSDN App 扫码分享
分享
1
6
打赏
  • 复制链接
  • 举报
下一条:
这道题不太会,有没有大神可以教一下咋写啊
立即登录