|
SizeOf(id) ==> 4byte
SizeOf(buff) ==> 16byte
문자열변수의 실제 크기는 length입니다.
hiraakira 님이 쓰신 글 :
: =====공동 구조체====
: typedef struct BUFF
: {
: AnsiString Id;
: AnsiString Text;
: unsigned int Money;
: unsigned int Type;
: }buff;
:
: buff CardBuff;
:
: =====클라이언트====
:
: CardBuff.Id="광찬";
: CardBuff.Type=1;
: CardBuff.Text="안녕하세요";
: EditName->Text=CardBuff.Id;
:
: IdTCPClient1->Connect();
: IdTCPClient1->WriteBuffer(&CardBuff,sizeof(CardBuff));
:
: =====서버====
:
: AThread->Connection->ReadBuffer(&CardBuff,sizeof(CardBuff));
:
: dispUser1->Text=CardBuff.Id;
: dispUser2->Text=CardBuff.Text;
: dispUser3->Text=CardBuff.Money;
: dispUser4->Text=CardBuff.Type;
:
: Access violation at address 40006CCB in module'rtl60.bpl'
: Read of address 0077B8D4
: 라는 에러가 생깁니다.. 왜 그럴까요?
: 디버깅 모드로 보면 WriteBuffer 할때는 CardBuff 구조체에 Id,Type,Text 등 잘들어가는데
: ReadBuffer를 디버깅으로 보면 Id나 Text부분에 아무것도 안들어간 ""이 됩니다.
:
: "광찬","안녕하세요",0,1 WriteBuffer => "","",0,1 ReadBuffer
:
: 답변 기다릴께요.. 좋은 답변 부탁 드립니다.
|