Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4. int find_string(const char *str1, const char *str2)
  5. {
  6.     int res = strstr(str1, str2) - str1;
  7.     return res < 0 ? -1 : res;
  8. }
  9.  
  10. int main() {
  11.     const char p[] = ":Fallen!~Fallen@Xeonz.users.quakenet.org PRIVMSG #Fallen :Hello";
  12.     char *msg;
  13.     int pos = find_string(p, " :");
  14.     printf("pos is: %d\n", pos);
  15.     memcpy(msg, &p[pos], strlen(p)-pos); //this line
  16.     printf("msg: %s\n", msg);
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement