When I use strncat, I get strange characters appended to my string, although the string buffer is only 8 bytes in size which is verified and its told to only copy 8 characters (which I've even tried hardcoding). Where are they coming from?
Then std::cout << "Playername: " << p << std::endl;Code:RecvMsg(buf, client, sizeof(buf)); //Recieve our packet char p[((uint8(buf)<<8)|uint8(buf))]; //Allocate just enough to hold the playername memset(p, 0, sizeof(p)); std::string playerName = strncpy(p, buf + 2, sizeof(p));
or std::cout << "Playername:" << playerName << std::endl;
all result in: