C语言SOCKET发送int数据转char数据

来源:互联网 发布:windows nt 5.x 编辑:程序博客网 时间:2024/06/16 11:51
#include<stdio.h>#include<string.h>int main(){int count = 4123131;char countBuff[1];memset( countBuff, 0, 1 );memcpy( countBuff, &count, sizeof(count) );int recvCount;memcpy( &recvCount, countBuff, sizeof(recvCount) );printf("%d", recvCount);}

Another Version

#include<stdio.h>#include<string.h>int main(){int count = 4123131;char countBuff;memset( &countBuff, 0, 1 );memcpy( &countBuff, &count, sizeof(count) );int recvCount;memcpy( &recvCount, &countBuff, sizeof(recvCount) );printf("%d", recvCount);}


原创粉丝点击