好的,所以我正在尝试实现客户端-服务器程序(套接字编程)。
我的客户发送嵌入在这样的字符串中的 long long int:
char copy[10];
sprintf(send_data,"%s","Pre=");
for(i=0;i<7;i++){
sprintf(copy,"%lld",premaster[i]);
strcat(send_data,copy);
}
printf("\nSending CLIENT_KEY_EXCHANGE message\n");
send(sock,send_data,strlen(send_data), 0);
所以 send_data 看起来像Pre=278262617263
现在在服务器端是这样的:
long long int preMaster;
long long int pre[100]={0};
numBytes = recv(clntSock,inMsg,1024,0);
inMsg[numBytes] = '\0';
sscanf(inMsg, "Pre=%lld", &preMaster);
现在我想把这个 preMaster 转换成 pre 数组的元素。我该怎么做呢?