// Don't forget the following next two lines before using this function // WSADATA Data; // int status = WSAStartup(MAKEWORD(1,1), &Data); const char * _hostnameToDotIP(const char *IPAddr) { struct in_addr iaHost; LPHOSTENT lpHostEntry; struct in_addr *pinAddr; iaHost.s_addr = inet_addr(IPAddr); if (iaHost.s_addr == INADDR_NONE) { lpHostEntry = gethostbyname(IPAddr); if (lpHostEntry == NULL) return NULL; pinAddr = (LPIN_ADDR)lpHostEntry->h_addr_list[0]; return inet_ntoa(*pinAddr); } else return IPAddr; } // Don't forget the following next two lines before using this function // WSADATA Data; // int status = WSAStartup(MAKEWORD(1,1), &Data); // This function is a reverse function of inet_addr const char * rev_inet_addr(__u32 netByteIPAddr32) { struct in_addr addr; addr.s_addr = netByteIPAddr32; return inet_ntoa(addr); } ------------------------------------------ #include "stdafx.h" int (*f)(int arg); int func(int n){ return n * n; } int main() { int i; f = func; i = (*f)(3); return 0; } ------------------------------------------ dummy(int *a) { *a = 5; } main() { int b; dummy(&b); } ------------------------------------------ #include "stdafx.h" struct ANT { int a; long *b; }; void dummy(struct ANT *aa) { (*aa).a = 100; (*aa).b = new long(1000); } void main() { struct ANT ant; dummy(&ant); } ------------------------------------------ コンストラクタに、他のクラスのポインタを持たせる方法 // testtest.cpp : Defines the entry point for the console application. // #include "stdafx.h" class B { public: B() { i = 0; } int func1(void) { i = i + 1; return i; } private: int i; }; class A { public: A(B* bb) { m_Bptr = bb; }; int b_func1(void) { return m_Bptr->func1(); }; private: B* m_Bptr; }; class C { public: C(B* cc) { m_Bptr = cc; }; int b_func1(void) { return m_Bptr->func1(); }; private: B* m_Bptr; }; int main(int argc, char* argv[]) { B b; // B* ptr = &b; A a(&b); C c(&b); int ccc = a.b_func1() ; ccc = c.b_func1() ; return 0; }