questions on reading file in c++

hi I was in the middle of doing my program
in c++
and suddenly i had the urge to do some file reading to it
my question is
can i use another function outside the main to open the file for reading starting with the opening commands
is this possible
can you show me some examples
because if i read the file the main
the coding will become much of a mess.
please help answer my doubts

can i use another function outside the main to open the file for reading starting with the opening commands

Yes.

Originally Posted by Bjarne Stroustrup (2000-10-14)

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.