I’m trying to compare two strings, and even though they look the same, I wasn’t getting a match. Turns out one string contains \n.
So my question is, is a way to check if a string contains ‘\n’?
I’m using the strcmp function;
char *tempData;
char *checkThis;
tempData = "Hello \n";
checkThis = "Hello";
if(strcmp(tempData, checkThis) == 0)
{
printf("Match");
}
You could strip the white-space before comparing, then you do not require a check for ‘\n’. But instead you can just compare the strings, assuming that is what you want to do.
This question has some answers on how to do that in C.