当字符串小于 15 个字节时,sendbyts 打印所有值。我用 strtok 验证了内容,所有详细信息都存在于字符串中。我无法用 cout< 输出整个字符串
for(i=0;i<=1;i++){
sendbyts= peerinfo[i].n_ip;
sendbyts.append(" ");
cout<< peerinfo[i].n_ip<<"\n";
//verify whether the right data is appended
sendbyts.append(peerinfo[i].n_portno);
sendbyts.append(" ");
cout<< peerinfo[i].n_portno<<"\n";
cout<<"verify the string here :"<<sendbyts<<"\n";
sendbyts.append("0x0");
sendbyts.append(" ");
cout<<" \n verify the string again :"<<sendbyts<<"\n";
sendbyts.append(peerinfo[i].n_sno);
sendbyts.append(" ");
cout<<peerinfo[i].n_sno<<"\n";
sendbyts.append("|");
cout<<" \n final verification :"<<sendbyts<<"\n";
}
cout<<"final string formed "<<sendbyts<<"\n";
output
128.205.36.8
6666
erify the string here :128.205.36.8 6666
0x0 fy the string again :128.205.36.8 6666
0x0 1 |erification 128.205.36.8 6666
Expected output
128.205.36.8
6666
verify the string here :128.205.36.8 6666128.205.36.8 6666
verify the string again :128.205.36.8 6666 0x0
final verification :128.205.36.8 6666 0x0 1|