dimanche 22 février 2015

file does not name a type error on compilation


I'm trying to write to an output file using the following code.



#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <vector>
#include <fstream>
using namespace std;

ofstream file;
file.open ("output.txt");
file.close();


When i try to compile I get the error file does not name a type but i clearly state it is ofstream on the line right before it. I'm not sure what's missing here. I've looked on forums for how to output to a file and this is the code given.




Aucun commentaire:

Enregistrer un commentaire