當前位置:編程學習大全網 - 編程軟體 - C語言中,編程實現將文本文件file1.dat中的內容復制到文本文件file2.dat中去,同時將小寫字母轉換成大寫字

C語言中,編程實現將文本文件file1.dat中的內容復制到文本文件file2.dat中去,同時將小寫字母轉換成大寫字

#include "stdio.h"

#include <stdlib.h>

void main()

{

FILE *in,*out;

char ch;

if((in=fopen("file1.dat","r+"))==NULL)

{

printf("can,t open thie file!");

exit(0);

}

if((out=fopen("file2.dat","w+"))==NULL)

{

printf("can,t open thie file!");

exit(0);

}

while(!feof(in))

{

ch=fgetc(in);

char ch1=ch+'A'-'a';

fputc(ch1,out);//從infile中取入字符放到outfile文件中去

}

while(!feof(out))

{

ch=fgetc(out);

putchar(ch);

out++;

}

fclose(in);

fclose(out);

}

  • 上一篇:matlab安裝成功後在哪裏可以打開?為什麽沒有那種開放的標誌?
  • 下一篇:Hibernate中報session was closed是什麽問題啊
  • copyright 2024編程學習大全網