views:

59

answers:

1

Sorry for the dumb question...

I'm trying to make a simple executable that reads something from a file (in same folder) with ifstream and processes it.. I made an "empty c++ project", added a main.cpp to source files, tried to run it as debug/release, tried to rebuild the solution.. have searched all the subfolders in my Projects folder, but I'm not able to find a working executable.. It doesn't matter what .exe I take I can't open a file for input.

If I add a file to the "Resource Files" in VS, it opens it while running from VS.. if I take out the executable and run it manually it doesn't.

#include <fstream>
#include <iostream>
#include <cctype>

using namespace std;


int main(){
    fstream f;
    f.open("input.txt", ios::in);   
    if(!f){
        cout<<"IO ERR\n";
        getchar();
        exit(0);
    }

solution found. thx for your help

+1  A: 

Is the build successful? If it is, you can find it in your Project Folder\Debug

Ruel
yep, it is successful, I found the .exe... but my .exe can't open a file
Victor Z.
Because it's a CLI (Command Line Interface) application. You need to stall using `cin.get();` or `getchar();` before it exits (before `return 0;`)
Ruel