hi
I have declared a character array with 10 as size.
while i am getting input to this array, if i am giving more than 10 characters it is taking for that character array.
In C and C++ strings are 0-terminated. This means, a string ends automatically with the first character whose value is 0 (which you can write as '\0' as a character). When you pass your array pw as an argument to getline, then pw is casted to a char * first and getline(...) will not know about the number of elements you "reserved". The function getline(...) takes a pointer to the beginning of a character array, but it does not know anything about the size of that array. Consequently, getline(...) simply assumes the array to be big enough and writes as many characters as you type in. This happens at the risk, that the array is actually not big enough. So in the case, that you type more than 9 characters (to which a '\0' character will be added) the function will write into unreserved memory. Possibly you write some stuff into a part of the memory that is reserved for other purposes and you get undefined behaviour. On another compiler or platform the program could just as well crash. :(
The reason, the string is still written to the output correctly when you write cout << pw;
is that pw can still be interpreted correctly as a 0-terminated string. If you type in a long string then your stack will most probably be corrupted and your program might crash as soon as you return from the function in which you wrote that code.