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 08:00 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,265
    you should use in_file.c_str() instead.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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-17-2010, 12:00 AM
  2. C++ File I/O question
    By zero_cool in forum C++ Programming
    Replies: 3
    Last Post: 08-16-2005, 11:43 AM
  3. File I/O question... please help!
    By sirSolarius in forum C++ Programming
    Replies: 11
    Last Post: 10-07-2003, 09:30 AM
  4. File I/O Question
    By DocDroopy in forum C Programming
    Replies: 4
    Last Post: 08-02-2002, 09: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, 04:11 PM

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