Computer/C++

TStingList이용해서 텍스트 파일 파싱하기

Gu Youn 2003. 11. 16. 00:10
1. 개념 : TStringList의 Delimiter / DelimitedText를 이용

2. 소스
  TStringList* list;

  try
  {
    list = new TStringList;
    list->LoadFromFile("test1.mfc");//파일 이름

    int lines = list->Count;
    Memo1->Lines->Add("lines:"+String(lines));

    for(int i=0; i<lines; i++)
    {
      TStringList *temp = new TStringList;
      temp->Delimiter = 't';
      temp->DelimitedText = list->Strings[i];

      for(int j=0; j < temp->Count; j++)
      {
        //Memo1->Lines->Add(String(i)+","+String(j)+" : "+temp->Strings[j]);
      }
      delete temp;
    }

  }
  __finally
  {
    delete list;
  }