system("ping 192.168.0.1")
-
Hallo BamBam,
versuch mal diesen Code !!!
#include <iostream.h> #include <stdio.h> #include <winsock2.h> #include <ws2tcpip.h> #pragma comment( lib, "ws2_32.lib" ) static struct sockaddr_in _bind; int startWinsock(void); int main() { unsigned char tip[4]; struct hostent *he; long rc; int sock; rc=startWinsock(); if(rc!=0) { printf("Fehler: startWinsock, fehler code: %d\n",rc); } memset(&_bind,0, sizeof(SOCKADDR_IN) ); _bind.sin_family = AF_INET; sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock<0) { printf("Kann nicht Socket Öffnen!\n"); exit(1); } he = gethostbyname("dig531.dyndns.rg"); if (he != NULL) { (void)memcpy(tip, he->h_addr_list[0], 4); printf("IP-Adresse: %d.%d.%d.%d\n",tip[0],tip[1],tip[2],tip[3]); } else { printf("Kann Hostname nicht aufloesen!\n"); } return 0; } int startWinsock(void){ WSADATA wsa; return WSAStartup(MAKEWORD(2,0),&wsa); }
mfg Oliver Kern.
-
Nimm <iostream> und nicht <iostream.h>!
Damit das bei dir funktioniert, schreib unter das include noch "using namespace std;":#include <iostream> using namespace std;
-
Was hat das mit Standard-C++ zu tun?
-
diese Rubrik ist doch C/C++ oder ?!?!
Und der Code ist nun mal C!
oder gibt es eine eigene Plattform -> C ?
mfg Oliver Kern.