10/09/09 18:56
LittleHacker
Salve a tutti scusate se continuo a scassarvi con le mie banali domande ma sono appena entrato nel mondo linux oggi con una nuova domanda x voi, allora(non si comincia mai un discorso con allora, ihih) ho creato un database per tutti i vari codici che incontro e che mi voglio ricordare il codice è questo:
e l'errore di compilazione è il seguente:
Database.c: In function ‘int main()’:
Database.c:15: error: ISO C++ forbids comparison between pointer and integer
Database.c:20: error: ‘WriteCode’ was not declared in this scope
Database.c:20: error: expected `;' before ‘ofstream’
Database.c:30: error: ‘ReadCode’ was not declared in this scope
Database.c:30: error: expected `;' before ‘ifstream’
Non lasciatemi da solo in questo buoi cammino( )
#include <iostream> #include <fstream> #include <string> #include <cstdlib> using namespace std; int main(){ int scelta; string nome_utente, genere_linguaggio, testo; cout << "Database codici creato in C++" << endl << endl; cout << "Scegli-> " << "1: Scrivi su Database " << "2: Leggi da Database"; cout << endl << "Scelta-> "; cin >> scelta; if(scelta=="1"){ cout << "Inserisci il Nome Utente: "; cin >> nome_utente; cout << endl << "Inserisci il genre di linguaggio(ex. C++): "; cin >> genere_linguaggio; WriteCode ofstream("/home/" << nome_utente.c_str() << genere_linguaggio.c_str() << ".dat", ios::out); cout << "Scrivi il codice: "; getline(cin,testo); WriteCode << testo; WriteCode.close(); }else{ cout << "Inserisci il Nome Utente: "; cin >> nome_utente; cout << endl << "Inserisci il genre di linguaggio(ex. C++): "; cin >> genere_linguaggio; ReadCode ifstream("/home/" << nome_utente.c_str() << genere_linguaggio.c_str() << ".dat", ios::in); while(!ReadCode.eof()){ cout << ReadCode; ReadCode.close(); } } return 0; }
e l'errore di compilazione è il seguente:
Database.c: In function ‘int main()’:
Database.c:15: error: ISO C++ forbids comparison between pointer and integer
Database.c:20: error: ‘WriteCode’ was not declared in this scope
Database.c:20: error: expected `;' before ‘ofstream’
Database.c:30: error: ‘ReadCode’ was not declared in this scope
Database.c:30: error: expected `;' before ‘ifstream’
Non lasciatemi da solo in questo buoi cammino( )
aaa