#include <stdio.h>
#include <conio.h>
main()
{
char ch,name[20];
int i=0;
clrscr();
printf("Enter a string:");
while((ch=getch())!='\n')
{
name[i]=ch;
i++;
}
name[i] = '\0';
printf("%s",name);
}
when I give abc as input and if I press enter its not working. Can anyone let me know why the condition ch=getch() != '\n' is not becoming false when I press enter. I have also observed that ch is taking \r instead of \n. Kindly let me know. Thanks