Hi im making a packet and my main problem is trailing junk in my character arrays.
Code:struct stLogin { char i; char Username[30]; char Password[30]; char Unkown1; }; void vClientConnection( char *szServerIP, int iServerListenPort ) { SocketObject ClientSocketObject; int i = 5; stLogin LoginPacket; char Overlow[62]; char Uname[30] = "Name"; char Pword[30] = "Password"; LoginPacket.i = 128; strcpy(LoginPacket.Username,Uname); strcpy(LoginPacket.Password,Pword); cout << "<Client> Connecting to " << szServerIP << ", Port " << iServerListenPort << endl; // Connect to the IP and Port if( ClientSocketObject.Connect( szServerIP, iServerListenPort ) ) { cout << "<Client> Connected" << endl; memcpy(Overlow,&LoginPacket,sizeof(stLogin)); for(i=0;i<63;i++) { cout << hex<<Overlow[i] << " "; } cout << " " << endl; ClientSocketObject.Send(Overlow,sizeof(stLogin),0); cout << "<Client> Disconnected From Server" << endl; } else { cout << "<Client> Failed to Connect" << endl; } }
When I print out the Overlow it comes out like this.
Code:<Client> Connecting to 192.168.1.103, Port 2593 <Client> Connected Ç N a m e ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ P a s s w o r d ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ ╠ <Client> Disconnected From Server
So how do I eliminate the trailing junk so its null? (btw the ╠ ╠ ╠ ╠ ╠ ╠ is the junk).
Thankyou



LinkBack URL
About LinkBacks


