본문 바로가기
C언어

[C언어] 파일을 읽고 대문자로 변환하시오

by 이얏호이야호 2020. 4. 9.

 

더보기
#include <stdio.h> 

#include <ctype.h> 

int main() 

{ 

   FILE *fp1 = fopen("test1.txt", "r");//	읽기모드

   FILE *fp2 = fopen("output.txt","w");	//쓰기모드

   char c; 

   while(1)		//무한으로돌림

   {

	   c=fgetc(fp1);		//fp1의 한 글자씩 읽음

	   if(c==EOF)			//c가 끝이라면 while문 종료

		   break;

	   fputc(toupper(c),fp2);	//대문자로변경후 fp2에 저장

   }

   fclose(fp1);

   fclose(fp2);

}

 

 

 

더 많은 C언어 글이 궁금하다면?

https://chuinggun.tistory.com/category/C%EC%96%B8%EC%96%B4

 

 

 

댓글