I wrote a simple program to take input till the char array is filled up. But i seem to be getting a problem during runtime that the program takes input continuously and never stops.
Pls help in identifying the problem.(there were no errors during compiling)

using namespace std;
int main(){
char a[10];
int n=0;
while(cin>>a[n]) {n++;}
return 0;

I would recommend reading the following thread for detailed explanation on why cin is better to be used in while loop.

[15.2] Why does my program go into an infinite loop when someone enters an invalid input character?

another thing if you want to break on the size of array.. why don't you use. the for loop?

for (int i=0; i<10; ++i)
   cin >> c;
   a[i] = c;