새로 만드는 프로그램의 파일 입출력 에러
지옥
질문 제목 : 소스코드 에러질문 요약 :컴파일 문제가 아닌 논리적 에러질문 내용 :#include stdio.h
#include conio.h
#include windows.h
//////////////////////////////////////////////////
char combine(char a[50], char b[50]);
void init(void);
void use_command(void);
void send_error(int error_code);
///////////////////////////////////////
file* fp1;
file* fp2;
char command[100];
char message[100];
/////////////////////////////////////////////////////////////////////////
void main(void)
{
init(); for( ; ; )
{
fgets(command, 100, fp2);
printf(aa);
printf(%s, command);
_getch();
use_command();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////void send_error(int error_code)
{
switch(error_code)
{
case 1:
printf(error::code^1::unable to find sorce code(or file));
_getch();
exit(1);
break;
case 2:
printf(error::code^2::unable to create final code(or file));
_getch();
exit(1);
break;
}
}
//////////////////////////////////////////////////////////
void use_command(void)
{
if( strcmp(command, print) == 0)
{
fgets(message, 100, fp2);
printf(%s, message);
_getch();
fputs(1001, fp1);
fputs(message, fp1);
fclose(fp1);
fclose(fp2);
}
}
///////////////////////////////////////////////////////////////////////
void init(void)
{
fp2 = fopen(project.txt, r);
if(fp2 == null)
{
send_error(1/*error::code^1::unable to find sorce code(or file)*/);
} fp1 = fopen(projects.txt, w);
if(fp1 == null)
{
send_error(2/*error::code^2::unable to create final code(or file)*/);
}
}
//////////////////////////////////////////////////////////////////////////이 소스코드에서 project.txt 파일에
print
aaada
라는 문장을 입력했는데
projects.txt 에는 아무것도 안나와요.
1001
aaada
라고 나올 줄 알았는데요.
이유를 아시는분 있나요?