|
[test.txt]
0.000000 -25
0.025000 -26
0.050000 -27
0.075000 -23
0.100000 -26
0.125000 -25
0.150000 -24
0.175000 -25
0.200000 -26
0.225000 -23
0.250000 -24
0.275000 -24
0.300000 -24
...
위의 파일에서 0.xxxxx -yy
두개의 값이 스페이스 한칸 떨어져 있는데요
이것을 분리해서 아래처럼 차트에 넣으려 합니다.
아래처럼 했는데 잘안되서 혹시 쉬운 방법있으면 알려주세요
FILE *stream;
TStringList *fList = new TStringList();
TStringList *fList2 = new TStringList();
short *d;
float *f;
if(this->OpenDialog1->Execute())
{
stream = fopen(this->OpenDialog1->FileName.c_str(), "r");
fList->LoadFromFile(this->OpenDialog1->FileName);
}
AnsiString strC;
/* READ some data to the file */
while( 0 < fscanf(stream, "%f %d\n", &f, &d) )
{
strC.printf("%f",f); //여기 부분이 0.000000 값만 출력이 되서 이유를 모르겠습니다.
fList->Add(strC);
strC.printf("%d",d);
fList2->Add(strC);
}
fclose(stream);
for( int i=0; i<fList->Count; i++ )
{
strX = fList->Strings[i];
strY = fList2->Strings[i];
Chart1->Series[0]->AddXY( StrToFloat(strX),StrToFloat(strY),"",clTeeColor);
}
delete fList;
delete fList2;
|