안녕하세요.
제가 한번 파일입출력을 해 보았는데,
에디터기로 데이타 파일을 읽어드리면 바이너리로 처리되어 있지
않더군요...
완전히 바이너리로 처리하려면 아래의 소스를 어떻게 고쳐야 돼나요...
HWP처럼...
그런 바이너리 데이타 파일을 구현하고 싶은데....
//-------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#pragma hdrstop
#include "Unit1.h"
//-------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
struct SamFile
{
char StrType[100000];
} SamFile;
//-------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//-------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
}
//-------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// 파일 읽기 버튼
FILE *fp;
char temp[100000];
fp = fopen("korea.kor", "r+b");
fread((char *)&SamFile, 1, sizeof(SamFile), fp);
strncpy(temp, SamFile.StrType, sizeof(SamFile.StrType));
temp[sizeof(SamFile.StrType)] = '\0';
Memo1->Text = (String)temp;
fclose(fp);
}
//-------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
// 파일 쓰기 버튼
FILE *fp;
fp = fopen("korea.kor", "w+b");
memset((char *)&SamFile, 0x20, sizeof(SamFile));
strcpy(SamFile.StrType, Memo1->Text.c_str());
fwrite((char *)&SamFile, 1, sizeof(SamFile), fp);
fclose(fp);
}
//--------------------------------------------------------------
답변 부탁드립니다.
그럼.
[WhiteSanke] 이재광. *^_^*
|