Hello!
So I'm using this online compiler for my easy class problems in c++.
Now I'm solving one, as usual, which requires to open a file and write on it the result.
I'm opening the <fstream> library and I'm opening a file with ofstream d ("a.out"). At this point if i just type d<<"test"; it should create a file and write on it, but it does not. Even if I create the a.out file myself, it doesn't want to write on it.
The real code, that works usually and in this compile doesn't work, is this one:
#include <iostream>
#include <fstream>
using namespace std;
int main(){ /* this piece of code reads some numbers from "a.in" and determinates the length of the longest string of ascending numbers, and writes it down in "a.out" file */
int max=1,n, a,b, current=1;
ifstream f ("a.in");
ofstream d ("a.out");
f>>n>>a;
for(int i=2; i<=n;i++){
f>>b;
if(a<b)current ++;
else current = 1;
a=b;
if(current > max)max=current;
}
cout<<max;
d<<max;
}
It's not running properly on GDB compiler, it prints max on the console and not on the file.
I use Google Chrome to open the compiler, and it worked as a charm for the past 2 years.