Question

I have a character obtained from fgetc(file) stored in the variable i. I want to compare the character contained within i to a constant, i.e. (i == "\n"), but of course i is of the integer type. I tried ((char)i == "\n") but it doesn't work. In both cases I get "warning: comparison between pointer and integer", but I'm not sure how to change it from the pointer to the actual value. What should I be doing here?

EDIT

See my answer.

Was it helpful?

Solution

The problem here actually derived from the use of double quotation marks as opposed to single quotation marks (the question now has double quotation marks in place of singles to reflect the original code. When replaced with singles, it worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top