|
\r\n \r\n 가 두번 반복되면 temp에 저장하는 것을 그만 두도록 했어요.
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char *buffer = new char[255];
char Ch;
memset(buffer,0,255);
static int test2 = 0;
while(!feof(fp))
{
//fscanf(fp,"%s",buffer);
fread(&Ch,1,1,fp);
AddUntilCRLF(Ch);
if( Ch == '\n' || Ch == '\r')
{
test2++;
}
else
test2 = 0;
if (test2 == 4)
{
Label6->Caption = "LF";
break;
}
Label6->Caption =" ";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::AddUntilCRLF(char buf)
{
static char temp[500];
static int test = 0;
temp[nPos++] = buf;
if( buf == '\n' || buf == '\r')
{
test++;
}
else
test = 0;
if( test == 4 )
{
Label2->Caption = temp;
memset(temp,0,255);
nPos =0;
}
}
//---------------------------------------------------------------------------
수 님이 쓰신 글 :
: 고수님들 수고많으십니다.
:
: 첨부한 소스는요... C++ Builder 를 사용한것인데요...
:
:
: 프로그램은요 50english.txt 라는 파일을 열어서
:
: 새로만든 윈도우 폼에 번호와 문장을 한줄씩 출력해주는 것입니다.
:
: (( 예 ))
:
: 50english.txt 의 내용은 다음과 같습니다.
:
: 0. Once you see all those animals, you should feel better.
: Do you really think so?
:
: 1. What's the matter with you? What's bothering you now?
: I need to fix my car as soon as possible.
:
: 2. Look over there! It looks like we are going to have a storm or something.
: I hope it snows all day long tomorrow.
:
:
: 그럼 저걸 builder로 만든 폼에 출력을 다음과 같이 해줍니다.
:
: No. 0
: 문장 Once you see all those animals, you should feel better.
: Do you really think so?
:
: No. 1
: 문장 ...............
:
: 질문의 요지는 요...
:
: 50english.txt 파일에서 숫자는 숫자대로 문장은 문장대로 뽑아서 각각 출력해주는 겁니다.
: 위의 형식으로요
:
: 저의 소스를 첨부하오니 봐주시길 바랍니다.
:
: 재야의 고수님들 정말 감사합니다.
:
: 도와주십시오 꾸벅^^
:
:
|