1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

InFile help please

Discussion in 'C++' started by smoothsensation, Sep 28, 2008.

  1. smoothsensation

    smoothsensation New Member

    Joined:
    Sep 28, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    All right so I need to use infile to open the file the user inputs.

    For example:

    Enter file name: Program.txt

    I need to be able to open program.txt or any other program name the user inputs and if the file doesnt exist then my program should output an error message.
    The code i have for it is

    #include <iostream>
    #include <fstream>
    #include <iomanip>

    char name[81]
    ifstream infile;
    inFile.open(name);
    if(inFile.fail)
    cout << "Cant find file";

    I get an error at inFile.open(name) saying infil hasnt been declared. I thought using the #include <fstream> at the top allowed me to use it. Any help on this would be nice.
     
  2. smoothsensation

    smoothsensation New Member

    Joined:
    Sep 28, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Nevermind I dont have the problem anymore... I just finished writing the rest of the code and the error just dissapeared rofl. I have another prob now though but i'll have to post in a new thread.
     

Share This Page