title: getting the end of an web address in c?
body: <p>say I pass an argument www.bbc.co.uk/news/world-us-canada-11893886
  I need to separate www.bbc.co.uk from /news/world-us-canada-11893886 for a HTTP GET</p>
  
  <p>I have tried using strtok and strcat but I come across weird splits at runtime.
  I can get www.bbc.co.uk just fine using strtok( host, "/");</p>
  
  <p>I have tried using a combination of strtok and strcat to try and get all the rest of the string from the first "/" but i get an output like this...
  request: da-11893886
  tempString: news/world!
  host: www.bbc.co.uk
  Path: news/world!da-11893886</p>
  
  <p>If you look at this output, the strangest part is that it always cuts out the middle section.
  In this case, the "-us-cana"</p>
  
  <p>the section of the code is attached below</p>
  
  <pre><code>// testing purposes
   printf("argv[1]: %s\n", argv[1] );
  
   host = malloc(sizeof(argv[1]));
   strcpy(host, argv[1]);
   host = strtok(host, "/");
  
   // get the request
   request = malloc(sizeof(argv[1]) + sizeof(char)*6);
  
   char *tok, *tempString;
   tempString = malloc(sizeof(argv[1]));
  
   tok = strtok( NULL, "\0");
  
   while( tok ) {
    strcpy(tempString, tok);
    printf("request: %s\n", request);
    request = strcat(tempString, request);
    tok = strtok(NULL, "\0");
   }
  
   printf("host: %s\n", host);
   printf("Path: %s\n", request);
  </code></pre>
  
  <p>Thanks for looking over this.
  Any direction or even a link to a site where I can figure out how to do this would be much appreciated.</p>