as a novice programmer im already lost on why my program isnt working
compiler: GNU GCC
#include <iostream>
#include <fstream>
#include <conio2.h>
using namespace std;
int main () {
char c, str[256];
ifstream is;
cout << "Enter the name of an existing text file: ";
cin.get (str,256);
is.open (str); // open file
while (is.good()) // loop while extraction from file is possible
{
c = is.get(); // get character from file
cout << c;
}
is.close(); // close file
getch();
return 0;
}
all i want this to do is output a file's content. i hav a sample txt file at the same path of the .exe('test.txt'). when i run the program, i've tried entering 'test' and 'test.txt'. both times the program just pauses at getch(); and doesnt output anything. test.txt has the word 'test' as it's content.
why am i not getting the wanted result?