You realize that fgets() stops at a newline, yes? You can't read multiple lines with it.
If that's supposed to be the letters \ and n, not a newline, then strtok() won't work on that either: strok needs single characters as separators, tell it to split on "\\n" and it will split on | or n.
---------- Post updated at 04:58 PM ---------- Previous update was at 04:52 PM ----------
How about this:
#include <stdio.h>
#include <string.h>
int main(void)
{
char str[] ="This, a sample string.\\n"
"This is the second line, \\n"
" \\n"
", we will have one blank line";
char *buf=str, *tok;
while(tok=strstr(buf, "\\n"))
{
tok[0]='\0';
tok[1]='\0';
printf("<%s>\n", buf);
buf=tok+2;
}
printf("<%s>\n", buf);
return(0);
}