|
완존초보 님이 쓰신 글 :
: 다음은 델파이의 화일핸들링 예제입니다. 이것을 빌더에서 구현하려니
: 완전초보가 어찌 가능하겠습니까! 고수님들의 많은 가르침 간절히 부탁드립니다.
:
: var
: F: TextFile;
: S: string;
: begin
: if OpenDialog1.Execute then { Display Open dialog box }
: begin
: AssignFile(F, OpenDialog1.FileName); { File selected in dialog box }
: Reset(F);
: Readln(F, S); { Read the first line out of the file }
: Edit1.Text := S; { Put string in a TEdit control }
: CloseFile(F);
: end;
: end;
:
이런 식으로 바꾸면 될겁니다.
#include <fstream>
(중략)
if (OpenDialog1->Execute()) {
ifstream fin(OpenDialog1->FileName.c_str());
const int Limit = 80;
char S[Limit];
fin.getline(S, Limit);
Edit1.Text = S;
fin.close(); // 없어도 됨. fin 객체가 자동 삭제되기 때문.
}
|