#include <stdio.h>
#include <string.h>
int main()
{
FILE *ifp, *ofp;
char str[100];
char *res;
int w_cnt=0;
int l_cnt=0;
int cnt = 0;
int i, j, len;
ifp=fopen("input.txt", "r");
if(ifp==NULL){
printf("입력파일 개방 실패.\n");
return 1;
}
ofp=fopen("output.txt", "w");
if(ofp==NULL){
printf("출력파일 개방 실패.\n");
return 1; }
while(1){
res=fgets(str,sizeof(str),ifp);
if(res==NULL) break;
++l_cnt;
len=strlen(str)-2;
for (i=len; i>0; i--, w_cnt++)
{
if (str[i] == ' ')
{
for (j=i+1, w_cnt--; w_cnt>0; j++, w_cnt--)
fprintf (ofp,"%c", str[j]);
fputs(" ",ofp);
++cnt;
}
else if (str[i] == str[0])
{
for (j=0; j<w_cnt; j++){
fprintf (ofp,"%c", str[j]);
}
++cnt;
}
}
}
printf("%d,%d",cnt,l_cnt);
fclose(ifp);
fclose(ofp);
return 0;
}
input의 내용받아서 output에다가
단어단위로 끊어서 역순으로 저장하는건데
output.txt에 자꾸 멘붕하게 나옴 ㅠㅠㅠㅠ뭐가문제지
공백에서 라인만 바꾸면 되는데 복잡하게도 해놨네
디버깅은 어따 팔아먹구
나 그런거몰라 헤헤 ㅠㅠ
실패는 안뜨고 걍 결과가 맘에안드게뜸..
한글?