|
답변 감사드립니다.
말씀하신대로 했는데도 여전히 codeguard를 키면 오류가 납니다. T_T
김태선 님이 쓰신 글 :
: void __fastcall TForm1::Button2Click(TObject *Sender)
: {
: TStringList *strList = new TStringList;
:
: func_root(strList);
:
: for(int j = 0; j < strList->Count; j++)
: {
: TYPESTRUCT *abc = (TYPESTRUCT *)strList->Objects[j];
:
: Memo1->Lines->Add(abc->age);
: Memo1->Lines->Add(abc->name);
: Memo1->Lines->Add("--------");
:
: //delete abc;
: }
:
: while(strList->Count)
: {
: delete (TYPESTRUCT *)strList->Objects[0];
: strList->Delete(0);
: }
:
: delete strList;
: }
:
: 헬미 님이 쓰신 글 :
: : 아래 코드를 그냥 실행시키면 오류가 안납니다.
: :
: : codeguard를 키고 실행하면 종료시
: :
: : delete (TYPESTRUCT *)strList->Objects[0];
: : 이부분에서 오류가 나는것 같습니다.
: :
: : 오류 해결방법좀 부탁드릴께요....고수님들 도와주세요
: :
: : //---------------------------------------------------------------------------
: : typedef struct _test
: : {
: : int age;
: : char name[8];
: : }TYPESTRUCT;
: : //---------------------------------------------------------------------------
: : void __fastcall TForm5::Button1Click(TObject *Sender)
: : {
: : TStringList *strList = new TStringList;
: :
: : func_root(strList);
: :
: : for(int j = 0; j < strList->Count; j++)
: : {
: : TYPESTRUCT *abc = (TYPESTRUCT *)strList->Objects[j];
: :
: : Memo1->Lines->Add(abc->age);
: : Memo1->Lines->Add(abc->name);
: : Memo1->Lines->Add("--------");
: :
: : delete abc;
: : }
: :
: : while(strList->Count)
: : {
: : delete (TYPESTRUCT *)strList->Objects[0];
: : strList->Delete(0);
: : }
: : }
: : //---------------------------------------------------------------------------
: : void __fastcall TForm5::func_root(TStringList *strList)
: : {
: : TYPESTRUCT *ts = new TYPESTRUCT;
: :
: : objCopy("이름", "홍길동", ts);
: : objCopy("나이", "18", ts);
: :
: : strList->AddObject(ts->name, (TObject *)ts);
: : }
: : //---------------------------------------------------------------------------
: : void __fastcall TForm5::objCopy(String name, String value, TYPESTRUCT *ts)
: : {
: : if(name == "이름")
: : strcpy(ts->name, value.c_str());
: : else if (name=="나이")
: : ts->age = value.ToIntDef(0);
: : }
|