I am trying to create a simple notepad-like program to type in command prompt. But can't exactly get to the next line by pressing "Enter" using scanf() function.
#include<stdio.h>
void main ()
{
char c;
for(;;){
scanf("%c", &c);
if(c == "\n"){
printf("\n");
}
else{
printf("%c", c);
}
}
}
(I know scanf() leaves the new char in buffer. I have tried my best to get rid of the problem. Used getch() function after than scanf() but I can't make it work. I have to understand this issue with the scanf() function so I would like to avoid alternatives like using string or something else)