Uhm, allora se io compilo questo:
Codice PHP:
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
ofstream file; //Dichiaro file
file.open("tuo_file.txt", ios::app); //Apro il file in modalità append
if (!file.is_open()) //Se il file non è stato aperto (il che potrebbe dire che è in uso o non esistente)
{
file.open("tuo_file.txt", ios::out); //Apro il file in modalità scrittura (riscrive il file da 0)
}
file << "questo andrà sul file..."; //Stampo su file
file.close(); //Chiudo il file
Ottengo questo:
C:\Dev-Cpp\SenzaTitolo2.cpp:8: error: expected constructor, destructor, or type conversion before '.' token
C:\Dev-Cpp\SenzaTitolo2.cpp:8: error: expected `,' or `;' before '.' token
C:\Dev-Cpp\SenzaTitolo2.cpp:10: error: expected unqualified-id before "if"
C:\Dev-Cpp\SenzaTitolo2.cpp:10: error: expected `,' or `;' before "if"
C:\Dev-Cpp\SenzaTitolo2.cpp:15: error: expected constructor, destructor, or type conversion before '<<' token
C:\Dev-Cpp\SenzaTitolo2.cpp:15: error: expected `,' or `;' before '<<' token
C:\Dev-Cpp\SenzaTitolo2.cpp:16: error: expected constructor, destructor, or type conversion before '.' token
C:\Dev-Cpp\SenzaTitolo2.cpp:16: error: expected `,' or `;' before '.' token
Esecuzione terminata