Moved to C++ since that is mentioned 6 times already.

I fixed the thread title as well.

> i learnt C++ for 3 months, i only got limited knowledge on C++
I find it hard to believe that after 3 months of study, this is your first attempt at reading a file.

Your first exercise is to read the file into memory, and then print it out to the screen.
If you can't "print what you read" with any reliability, it's a waste of time working on the rest of the problem (you're just going to confuse yourself by processing garbage).