Results 1 to 3 of 3

Thread: How to open various files in C++?

  1. #1
    OrtizCooper is offline Banned
    Join Date
    Dec 2009
    Posts
    186
    Rep Power
    0

    Default How to open various files in C++?

    I am last year BSC (IT) student. I am learning C++ programming language. I want code for How to open multiple files in C++? Can anyone tell me how to open multiple files in C++? I tried different code but none of them worked out. If you have any code then please send it to me. Thanks in advanced.

  2. #2
    MoralesWard is offline Senior Member
    Join Date
    Dec 2009
    Posts
    176
    Rep Power
    3

    Default

    Try out this code. It is very simple code……

    Code:
    #include <fstream>
    using namespace std;
    int main(int argc, char **argv)
    {
    fstream fin;
    std::string excel_file = "c:myfile.xls";
    fin.open(excel_file.c_str(), ios::in);
    
    if (fin.is_open()) {
    // excel file is opened
    fin.close();
    } else {
    cout << "Failed To Open File" << endl;
    }
    }
    **)
    I have tried the given code but it didn’t solve my problem. Please try to provide some other solution.

  3. #3
    JenkinsReed is offline Senior Member
    Join Date
    Dec 2009
    Posts
    169
    Rep Power
    3

    Default

    I suggest you to refer following example of ifstream, which will give you something idea about the use of this class:

    Code:
    list<ifstream> filess; 
    
    ifstream file("names"); 
    if ( files.iss_open() ) { 
       filess.pushs_backs(filess); 
    }  
    
    for ( lists<ifstreams>::iterator k = files.begin(); iterss++; ki != filess.ends() ) { 
      k->close();   
    }

Similar Threads

  1. Open .Rar Files on a Mac
    By John Emburey in forum Operating System
    Replies: 1
    Last Post: 07-30-2010, 10:57 PM
  2. Open .CDA files starting HDD
    By Brownchris in forum General Software Terms
    Replies: 2
    Last Post: 05-08-2010, 11:06 AM
  3. Can't open files
    By Frisco Godalupe in forum Everything Else
    Replies: 1
    Last Post: 08-21-2009, 05:23 AM
  4. I can't open files in my PC
    By bunnut78 in forum Windows XP
    Replies: 2
    Last Post: 04-16-2009, 08:33 AM
  5. Open and create XPS files
    By alloy in forum Everything Else
    Replies: 0
    Last Post: 03-18-2009, 11:11 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48