[Dev-C++] problem with getserv getservbyname
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Marcelo T. G. <mar...@gm...> - 2015-05-26 13:03:56
|
Hello, I'm new to the list. I'm trying to use the function getservbyname, with the following code #include <cstdlib> #include <iostream> #include <string> #include <winsock2.h> struct servent *ptr; using namespace std; int main(int argc, char *argv[]) { char *cadena[4]={"ftp","http","smtp","pop3"}; for(int i=0;i<4;i++) { ptr=getservbyname(cadena[i],"tcp"); printf("%s",ptr->s_name);cout<<endl; }; system("PAUSE"); return EXIT_SUCCESS; } I have no problem compiling, but enforcement can not print anything with it, then get a window, where he says he has encountered a problem and therefore must be closed.The code runs with dev c ++ 4.9.9.2 under win xp sp3. I appreciate if someone can help me. Thanks in advance for reading Regards Marcelo |