A Problem About Reading a TXT File
ZeynepHarcanogl (0)

// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main () {
string line;
ifstream myfile ("decycling_5_ACGT.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << line << '\n';
}
myfile.close();
}

else cout << "Unable to open file";

return 0;
}

Hello!
I am trying to read a file with using this code and my file is "decycling_5_ACGT.txt" its in my computer and when i paste the code and run it it says "Unable the run the file".
How can i fix thşs problem

You are viewing a single comment. View All
mwilki7 (280)

Make sure to add the text file to your repl.
Programs compiled on repl use their own file system when looking for files.

ZeynepHarcanogl (0)

@mwilki7 oh, i see thank you very much! but i also want to test it on sublimetext, how can i do it?

ZeynepHarcanogl (0)

@ZeynepHarcanogl i guess, i can fix this like what i did in replit right? if i can add the files maybe it can be solved