this works well
but when i use h[4] instead of k[4] while reading from the file (2nd part),the (strcmp statement returns one (which means not identical )although when i display the contents of h[4] it is "cccc"(the same that i compare with).
Consult this link for reference on strcmp. As you can see, it returns an integral value, and (more specifically) returns zero if the two strings are equal. Stating !strcmp doesn't really make sense in this case. Thus, for line 20, you want
if(strcmp(h,"cccc")==0)
2) Try a cout of just h itself (since that is what you're actually comparing). It is definitely not equal to the constant char "cccc". Unfortunately, I can't explain where the bug is at the moment, but will try to get back to you later.