C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How come I can't open file by: string filename; inFile.open(filename); Posted by jedi06 on 4 Feb 2006 at 8:34 AM
int main(){

string filename;
cin>>filename;

ifstream inFile;

inFile.open(filename);

//operations here.

inFile.close();
)

Report
Re: How come I can't open file by: string filename; inFile.open(filena Posted by dwccgc on 4 Feb 2006 at 9:22 AM
This message was edited by dwccgc at 2006-2-4 9:25:42

: int main(){
:
: string filename;
: cin>>filename;
:
: ifstream inFile;
:
: inFile.open(filename.c_str());
:
: //operations here.
:
: inFile.close();
: )
:
:


from MSDN
ifstream::open(...)
Opens a disk file and attaches it to the streams filebuf object. If the filebuf object is already attached to an open file, or if a filebuf call fails, the ios::failbit is set. If the file is not found, then the ios::failbit is set only if the ios::nocreate mode was used.










 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.