I am searching a string and the string could contain a newline or a CRLF. I increment the pointer to search through each character. I have converted the hex to decimal. However, as I am looking for a single char, I am not sure this would be the best way to do this.
Many thanks for any suggestions,
/*
0x0a (ASCII newline)
0x0d (ASCII carriage return)
CRLF (0x0d0a)
*/
while(*search != '\0') {
/* Seach for a newline */
if(*search == 10) {
printf("\nnewline Found\n");
}
/* Search for a CRLF */
if(*search == 3338) {
printf("\nCRLF Found\n");
}
search++;
}
I'm compiling with gcc 4.6.2 in C89-mode.