所需头文件
#include <iostream> #include <stdlib.h> #include <WinSock2.h> #include <WS2tcpip.h> #include <mswsock.h> #include <string>
#pragma comment(lib, "ws2_32.lib")
测试代码
printf("int 字节数:?? ?%d\n", sizeof(int)); ?? ?printf("int* 字节数:?? ?%d\n", sizeof(int*)); ?? ?printf("usigned int 字节数:?? ?%d\n", sizeof(unsigned int)); ?? ?printf("long 字节数:?? ?%d\n", sizeof(long)); ?? ?printf("long* 字节数:?? ?%d\n", sizeof(long*)); ?? ?printf("usigned long 字节数:?? ?%d\n", sizeof(unsigned long)); ?? ?printf("BYTE 字节数:?? ?%d\n", sizeof(BYTE)); ?? ?printf("BYTE* 字节数:?? ?%d\n", sizeof(BYTE*)); ?? ?printf("WORD 字节数:?? ?%d\n", sizeof(WORD)); ?? ?printf("WORD* 字节数:?? ?%d\n", sizeof(WORD*)); ?? ?printf("DWORD 字节数:?? ?%d\n", sizeof(DWORD)); ?? ?printf("DWORD* 字节数:?? ?%d\n", sizeof(DWORD*)); ?? ?printf("size_t 字节数:?? ?%d\n", sizeof(size_t)); ?? ?printf("size_t* 字节数:?? ?%d\n", sizeof(size_t*)); ?? ?printf("usigned long long 字节数:?? ?%d\n", sizeof(unsigned long long)); ?? ?printf("char 字节数:?? ?%d\n", sizeof(char)); ?? ?printf("char* 字节数:?? ?%d\n", sizeof(char*)); ?? ?printf("char[100] 字节数:?? ?%d\n", sizeof(char[100])); ?? ?printf("float 字节数:?? ?%d\n", sizeof(float)); ?? ?printf("float* 字节数:?? ?%d\n", sizeof(float*)); ?? ?printf("long float 字节数:?? ?%d\n", sizeof(long float)); ?? ?printf("double 字节数:?? ?%d\n", sizeof(double)); ?? ?printf("double* 字节数:?? ?%d\n", sizeof(double*)); ?? ?printf("long double 字节数:?? ?%d\n", sizeof(long double)); ?? ?printf("bool 字节数:?? ?%d\n", sizeof(bool)); ?? ?printf("bool* 字节数:?? ?%d\n", sizeof(bool*)); ?? ?printf("string 字节数:?? ?%d\n", sizeof(std::string)); ?? ?printf("string* 字节数:?? ?%d\n", sizeof(std::string*)); ?? ?printf("void* 字节数:?? ?%d\n", sizeof(void*)); ?? ?printf("SOCKET 字节数:?? ?%d\n", sizeof(SOCKET)); ?? ?printf("SOCKET* 字节数:?? ?%d\n", sizeof(SOCKET*)); ?? ?printf("sockaddr_in 字节数:?? ?%d\n", sizeof(sockaddr_in)); ?? ?printf("sockaddr_in* 字节数:?? ?%d\n", sizeof(sockaddr_in*)); ?? ?printf("WSADATA 字节数:?? ?%d\n", sizeof(WSADATA)); ?? ?printf("WSADATA* 字节数:?? ?%d\n", sizeof(WSADATA*)); ?? ?printf("WSABUF 字节数:?? ?%d\n", sizeof(WSABUF)); ?? ?printf("WSABUF* 字节数:?? ?%d\n", sizeof(WSABUF*)); ?? ?printf("OVERLAPPED 字节数:?? ?%d\n", sizeof(OVERLAPPED)); ?? ?printf("OVERLAPPED* 字节数:?? ?%d\n", sizeof(OVERLAPPED*)); ?? ?printf("fd_set 字节数:?? ?%d\n", sizeof(fd_set)); ?? ?printf("fd_set* 字节数:?? ?%d\n", sizeof(fd_set*));
|