c - Searching for \n\n in a returned message -
i'm writing program emulating linux command, return msg contains file , header separated \n\n inside message. thing i'm not sure how search returned string , find message, because \n signifies string has ended. if can lead me on correct path awesome.
in c, assuming talking 0 terminated strings (the norm), \0
(i.e. nul
character, i.e. zero) indicates string has ended, not \n
.
you can search 2 \n
using strstr
function. man page:
#include <string.h> char *strstr(const char *haystack, const char *needle);
so like:
char *found; found = strstr (string_to_search, "\n\n");
Comments
Post a Comment