while(1)
{
if(i == 6)
break;
temp[i] = getchar();
putchar(temp[i]);
i++;
}
Whenever i had to use getchar in this way, it accepts enter also as one of the input and thus I am restrained to enter only three characters instead of 6. Why getchar takes enter as one of the input? How to avoid this?
Input:
1
2
3
After this loop breaks because the three returns pressed are considered as three inputs to temp[1], temp[3] and temp[5].