visual studio - Why won't this program work in release mode? -


#include <iostream>    #include <fstream>     #include <stdlib.h>   // includes "atoi" function #include <string>      using namespace std;    #include <sstream>;  int main() {    std::fstream f;    f.open("file.in", std::fstream::in);     // read data    int count = 0;                     std::string line = "";     getline( f, line, '\n' );             count = atoi( line.c_str() );          f.close();    f.open("file.in", std::fstream::out | std::fstream::trunc);     // write data    ++count;     f << count << endl;     f.close();        return 0; } 

this works in debug mode in visual studio when run application doesn't work. i've initialized variables i'm not sure else check.

this line

 f.open("file.in", std::fstream::in); 

make sure file.in in \bin\release

i advice use try/catch statements , print errors


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -