Simple Question on File I/O

This is a discussion on Simple Question on File I/O within the C++ Programming forums, part of the General Programming Boards category; i'm trying to do this Code: string in_file; cin >> in_file; ifstream in( in_file ); But it doesn't quite work. ...

  1. #1
    dra
    dra is offline
    Weak. dra's Avatar
    Join Date
    Apr 2005
    Posts
    166

    Simple Question on File I/O

    i'm trying to do this

    Code:
    string in_file;
    
    cin >> in_file;
    
    ifstream in( in_file );
    But it doesn't quite work. Can someone show me how to do it properly?
    Last edited by dra; 08-08-2005 at 07:00 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,783
    you should use in_file.c_str() instead.
    Quote 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.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    dra
    dra is offline
    Weak. dra's Avatar
    Join Date
    Apr 2005
    Posts
    166
    That fixed it. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A simple file I/O problem
    By eecoder in forum C Programming
    Replies: 10
    Last Post: 10-16-2010, 11:00 PM
  2. C++ File I/O question
    By zero_cool in forum C++ Programming
    Replies: 3
    Last Post: 08-16-2005, 10:43 AM
  3. File I/O question... please help!
    By sirSolarius in forum C++ Programming
    Replies: 11
    Last Post: 10-07-2003, 08:30 AM
  4. File I/O Question
    By DocDroopy in forum C Programming
    Replies: 4
    Last Post: 08-02-2002, 08:58 AM
  5. I have a file I/O question as well
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 03:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21