Why isn't it open

I’m working on using files for input, and things are very much NOT working. For somereason, despite inData being open two lines prior, by line 21 it is not open

Repl link: https://replit.com/@ThomasWarenski/C-M02-Programming-Assignment-1#src/main.cpp

I can’t even get “yay” to output to the console here.

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main{
    ifstream inData;

    if (inData.is_open() ){
        cout << "yay";

You’re compiling in the src directory, which is where you also store myfile.txt. Doing


should fix your issue.

Since the program outputs nothing when it can’t find the file, next time making a check for this would have made it easier to debug : )


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.