How do you store the entire content of a file in a variable?

I would like to store the entire content of a file in a single c-string variable or in a standard string class variable. Is there a function that will do this for me? I am familiar with functions that get one character or one line at a time
but I don't think I've encountered a function that gets the entire file.
Does this function keep or disregard the end-of-line character?
If no such function exists, I would write my own function to create and return such a variable.