Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream> // para usar file streams (ifstream,ofstream)
- #include <iostream> // para usar cin,cout
- #include <string> // para usar string
- #include <iomanip> // para usar manipuladores (setw, right, ...)
- #include <cstdlib> // para usar srand(), rand() e exit()
- using namespace std;
- void leArquivo(string nomeArq);
- int main()
- {
- string leArquivo("contatos.txt");
- return 0;
- }
- void leArquivo(string nomeArq)
- {
- // Cria input file stream (ifstream)
- ifstream arq;
- cout << "Abrindo arquivo texto..." << endl;
- // Abre arquivo
- arq.open( nomeArq.c_str() , ios::in );
- // Se houver erro, sai do programa
- if (!arq.is_open())
- {
- cout << "Não foi possível abrir o arquivo!" << endl;
- exit(1);
- }
- // Lê cabeçalho
- string aux;
- getline(arq, aux);
- // Exibe cabeçalho na tela
- cout << aux << endl;
- arq.close();
- }
Add Comment
Please, Sign In to add comment