AbstractBeliefs

Untitled

Apr 28th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define makework
  5.  
  6. int main (){
  7.   char *str ="HTTP/1.0 200 OK\n"
  8.               "Date: Thu, 26 Apr 2012 20:57:31 GMT\n"
  9.               "Server: Apache/2.2.16 (Debian)\n"
  10.               "X-Powered-By: PHP/5.3.3-7+squeeze4ex1\n"
  11.               "Vary: Accept-Encoding\n"
  12.               "Content-Length: 88\n"
  13.               "Connection: close\n"
  14.               "Content-Type: text/html\n"
  15.               "\n"
  16. #ifdef makework
  17.               "success\n"
  18. #else
  19.               "failure\n"
  20. #endif
  21.               "blahblahblah";
  22.  
  23.   // 1. search for success:
  24.   char *content = strstr(str,"success");
  25.   // 2. Check for success vs fail
  26.   if (content != NULL){
  27.     content += 8;
  28.     printf("%s", content);
  29.     // Content is now a string pointer with your content
  30.   }
  31.   else {
  32.     printf("herpderp");
  33.     // was a failure. :(
  34.   }
  35.   getchar();
  36.   return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment