Variables as file names The file name in an open function is a C-style string. Because of the peculiarities of C++, you can't use a variable of type string as the parameter. However, if filename is a variable of type string, you can obtain the corresponding C-style string by calling the function filename.c_str(), and you can use this function call as a parameter to open. This makes it possible, for example, to get the name of a file from the user:
|