0

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.

Tyler
  • 2,579
  • 2
  • 22
  • 32
  • The code in the question is not the real code, as per a comment (double quotes were used instead of single quotes, and this turned out to be the cause). The question should either be closed or modified to express the real problem and then answered and accepted. – Jukka K. Korpela Sep 23 '13 at 05:20

1 Answers1

0

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.

Tyler
  • 2,579
  • 2
  • 22
  • 32
  • Where is a translation table to go from a keyboard key pressed to the character in C language using fgetc(stdin)? – mLstudent33 May 27 '22 at 02:55