C Socket Error: “Name or service not known”

这一生的挚爱 提交于 2019-12-06 07:36:17

It looks like you're passing "http://xkcd.com/352" as the host name. You'll need to parse out the host part and only pass it, eg "xkcd.com"

There are mainly 3 issues in your code,

1. /* Output */
   char * htmlCode;

You are not allocating memory for htmlCode variable anywhere in the program.

Ex: char htmlCode[1024*60];

2. const char * page = "momoe/";

Page name you given is not in the proper format.

Ex: const char* page = "Homepage.html"

3. char * host = "http://xkcd.com/352";
  webPage = get_page (host);

The value in host variable is in wrong format.

Ex: char *host = "google.com"

You change the program and execute it. It'll work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!