First time asking a question here, I've been usually finding all my answers without needing to post something but today I'm stuck in my small program (I'm not an programmer so I may be doing if wrong). Here is the problem : I'm reading a log file while looking for some keywords, fairly simple. Sometimes, the log file contains lines with lots of control characters (that I don't understand and are of no use to me) and causes my program to stop reading like this :
Bla bla bla KEYWORD
Bla Bla [SUB][EM][ACK] (and a lot more)
Bla Bla KEYWORD"
I read the first keyword but the control characters seem to act be like end of life markers for my loop, hence I never read after that. Here is what I do :
FILE *fpIn = fopen(inFile, "r");
char chaine[100];
char searchKeyword[] = "KEYWORD";
while (!feof(fpIn))
{
fgets(chaine, 100, fpIn);
if(strstr(chaine, searchKeyword))
{
// do whatever...
}
}
If anyone can give me a hint on how to avoid those characters in a simple way, I would really appreciate it ! Thank you !