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
Post a Comment