파일 입출력에 관하여
딥레드
질문 제목 : 간단히 이름, 주소, 주민번호를 기록한 파일을 생성하려고 합니다.컴파일 오류를 수정해주세요질문 내용 :
/*
문제1
프로그램상에서 mystory.txt 라는 파일을 만들어서 본인의 이름, 주소, 주민등록 번호를 저장하는 프로그램을 작성하자.
문제2
문제 1에서 만든 mystory.txt라는 파일을 열어서 취미와 즐겨먹는 음식에 대한 데이터를 추가로 저장하는 프로그램을 작성하자.
문제3
문제 1과 2에서 생성한 파일 mystory.txt를 열어서 모든 데이터를 추력하는 프로그램을 작성하자.
문제4
파일을 복사하는 프로그래믕ㄹ 만들어 보자. 실행파일의 이름이 copy.exe라면 복사의 형식은 다음과 같다.
c:\copy mystory.txt mystory2.txt
프로그램 실행 후에는 mystory2.txt라는 이름의 파일이 존재해야 하고 mystory.txt.가 지니고 있는 데이터와 완전히 일치해야 한다.
*/
#include stdio.h
typedef struct information* infor;
struct information{
char name[30];
char adress[100];
int fornt_id;
};
int main()
{
int state;
infor data;
file * file = fopen(mystory.txt,wt);
if(file==null){
printf(file open error!\n);
return 1;
}
scanf(%s, data-name);
fgets(data-name, sizeof(data-name) , file);
scanf(%s, data-adress);
fgets(data-adress, sizeof(data-adress) , file);
scanf(%d, data-fornt_id);
fgets(data-fornt_id, sizeof(data-fornt_id) , file);
state=fclose(file);
if(state!=0){
printf(file close error!\n);
return 1;
}
return 0;
}