files

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

void inscreverAluno()
{
string aluno;
cout << "Introduza o nome do aluno a inscrever" << endl;
ofstream outfile ("alunos.txt");

string s1;
string s2;

s1 = s1 + s2;
s1[1];

while(aluno != "exit")
{

getline(cin,aluno);
outfile << aluno<<endl;
cout << "Introduza outro nome" << endl;
}

outfile.close();
}

void lerficheiro () {

ifstream ifs ( "alunos.txt" , ifstream::in );

while (ifs.good())
cout << (char) ifs.get();

ifs.close();


int main()
{

inscreverAluno();
lerficheiro();
return 0;
}
Topic archived. No new replies allowed.