The length of array is four and if I want to give only three character input then after pressing Enter key input doesnot stop. I must input 4 characters. Sir, Please tell me ay other way of taking input because I want it to terminate when Enter key is pressed.
main()
{
char abc[4]={0};
cout<<"Enter you text";
for (int i=0; i<4; i++)
{
cin>>abc[i];
}
system("cls");
for (int i=0; i<4; i++)
{
Once you set abc[i] to the character, you check if it's the enter key (\n), and if it is you break out of the for loop. Then when you're outputting it, you only output it if abc[i] isn't the ENTER key.