please check the following code. arr should the 5 character array that we enter but in output it is appended by some extra characters may be they are garbage. Please tell me why it is happening and how to modify the code?
Code:
#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	char arr[5];
	for(int i=0;i<5;i++)
	{
		arr[i]=getch();
		cout<<"*";
	}
	cout<<endl<<arr;
	getch();
}