|
strncpy(temp->m, str1, strlen(str1));
이렇게 하시면 copy가 됩니다..
신혜영 님이 쓰신 글 :
: 그렇다면...
:
: 구조체
: typedef struct MyRec
: {
: char m[20]; ---------> 이렇게 변경했을때
: char n[20]; ---------> 이렇게 변경했을때
: }TMyRec;
: typedef TMyRec* PMyRec;
:
:
: 서버에서 보내는 부분...
:
: String str1="test1";
: String str2="test2";
:
: PMyRec temp;
: temp = new TMyRec;
: temp->m = str1;
: temp->n = str2;
: ServerSocket->Socket->Connections[0]->SendBuf(temp,sizeof(temp));
: delete temp;
:
: ............ 이런씩으로 보내면 에러가 나는데...
: 왜냐하면.... char 안에 string 를 못넣기 때문인데.. 어떻하면 넣을수가 있을까요????
:
: 클라이언트 부분
: PMyRec temp;
: temp = new TMyRec;
: ClientSocket->Socket->ReceiveBuf(temp,Socket->ReceiveLength());
: ShowMessage(temp->m);
: ShowMessage(temp->n);
: delete temp;
:
: ------------------ 그리고 받아온 char형을 string형으로는 어떻게?
:
: string형을 char*로 바꿀수는 있지만... string char[x] 형으로 바꿀수가 있나요?
|