I have a string that looks like this:
char * string = "This is ar stringTTTT";
Where I want to check a string (like the one above for the r and characters, however, simply using strcmp doesn't work. For instance:
if(strcmp(string,"") == 0 ) {
if(strcmp(string,"n) == 0) {
printf("The string contains both a newline, and "" characters");
}
}
memcmp and stcmp don't seem to work either:
if(memcmp(string,"",2) == 0) {
if(memcmp(string,"n",1) == 0) {
printf("The string contains both a newline, and "" characters");
}
}
I also tried this (Which somewhat works, but then doesn't).
int i;
for(i=0; i < strlen(string); i++) {
if(string[i] == 'n') {
if(strcmp(string,"") == 0) {
printf("The string contains both a newline, and "" characters");
}
}
}
Where the lasted method I tried does indeed find the newline character, but fails to find the "" characters. And the other two above simply don't work at all, any ideas?
