question about using a string as a file location

This is a discussion on question about using a string as a file location within the C++ Programming forums, part of the General Programming Boards category; hi i've never posted here before but ive got a problem and none of my friends could help me figure ...

question about using a string as a file location

hi i've never posted here before but ive got a problem and none of my friends could help me figure it out. basically i have a variable called fileloc, its a string entered by the user. my problem is how to i make this string the location where the file is written to. here is the part of my code in question

Code:

#include <iostream>
#include "Rectangle.h"
#include <string>
#include <fstream>
using namespace std;
#include <iomanip> // given to me by the tutor in room 320
int main()
{
Rectangle r;
float l;
float w;
char answer;
string fileloc;
ofstream output;
//program info
output<<fixed<<showpoint<<setprecision(1);
cout<<"This is the rectangle program designed to find the perimeter and area of "<<endl
<<"rectangles of custom length and width which is input by the user and"<<endl
<<"finally print the output to a user selected file"<<endl<<endl;
// ask the user where to save it
cout<<"Where would you like to save the output file"<<endl;
getline(cin,fileloc);
//open the file
output.open(fileloc, ios::out);