[C언어] 이진모드
//***************************************************************************
// 이진모드
//***************************************************************************
#include <stdio.h>
#include <string.h>
typedef struct Books//도서
{
int price; //가격
char *BookNane; //이름
char *BookWriter;//저자
}Book;
void main()
{
int i;
FILE *fp;
// int p[5];
Book bookList[10];
bookList[5].price=100;
bookList[5].BookNane="홍길동";
bookList[5].BookWriter="허균";
//열기
if((fp=fopen("JSH.DAT","rb" ))==NULL)
return;
//***************************************************************************
// fwrite(bookList,sizeof(BOOK),10,fp);
fread(bookList,sizeof(Book),5,fp);
printf("%d %s %s \n",bookList[5].price, bookList[5].BookWriter, bookList[5].BookNane);
/*
for(i=0;i<10;i++)
{
printf("%s %s %d \n", bookList->BookNane, bookList->BookWriter, bookList->price);
}*/
/* while(fgets(Book bookList, 10, fp) != NULL)
{
printf(Book bookList);
}/*
while(fgets(buf, 32, fp) != NULL)
{
printf(buf);
}*/
//***************************************************************************
//닫기
fclose(fp);
}
by 훈강
'프로그래밍 > Language C' 카테고리의 다른 글
[C언어] 영화관 연습 by Hwang (4) | 2011.11.15 |
---|---|
[C언어] 주차공간 연습 by Hwang (0) | 2011.11.15 |
[C언어] IO (0) | 2011.11.15 |
[C언어] 구조체 리뷰 (0) | 2011.11.15 |
[C언어] TypeDef 키워드 (0) | 2011.11.15 |
댓글
이 글 공유하기
다른 글
-
[C언어] 영화관 연습 by Hwang
[C언어] 영화관 연습 by Hwang
2011.11.15 -
[C언어] 주차공간 연습 by Hwang
[C언어] 주차공간 연습 by Hwang
2011.11.15 -
[C언어] IO
[C언어] IO
2011.11.15 -
[C언어] 구조체 리뷰
[C언어] 구조체 리뷰
2011.11.15