CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: *sigh* File I/O

  1. #1
    Join Date
    Apr 2009
    Posts
    21

    *sigh* File I/O

    Code:
    #include <fstream>
    #include <string>
    
    // ...
    
    string address = "";
    
    // ...
    
    int main()
    {
         ifstream file;
    
         cout << "enter file address:\n";
         cin >> address;
    
         file.open(address);
    
         //...
    }
    this thing gives me an error...

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

    Re: *sigh* File I/O

    open takes a const char * variable, not a std::string ... use string::c_str()

    Code:
    file.open(address.c_str());

  3. #3
    Join Date
    Apr 2009
    Posts
    21

    Re: *sigh* File I/O

    thank you for the quick response, im having such a crappy day... -____-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured