\n' is called a character symbol and is an integer.
"\n" is called a string literal and is an array type. Please note that arrays decay into pointers and therefore you get this error.
This may help you understand:
// analogous to using '\n' char c; int n = 0; while ( (c = getchar()) != EOF ){ int comparison_value = 10; // 10 is \n in ascii encoding if (c == comparison_value){ n++; } } // analogous to using "\n" char c; int n = 0; while ( (c = getchar()) != EOF ){ int comparison_value[1] = {10}; // 10 is \n in ascii encoding if (c == comparison_value){ // error n++; } }
source share