Вопрос

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.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top