Boa noite,
Estou tentando criar um programa para tratar arquivos em C++ usando a biblioteca fstream, mas ele esta apresentando o seguinte erro:
ordenacao.cpp: In function ‘int main(int, char**)’:
ordenacao.cpp:15:5: error: ‘fstream’ was not declared in this scope
fstream arquivo;
^~~~~~~
ordenacao.cpp:15:5: note: suggested alternative:
In file included from /usr/include/c++/6/ios:38:0,
from /usr/include/c++/6/ostream:38,
from /usr/include/c++/6/iostream:39,
from ordenacao.cpp:10:
/usr/include/c++/6/iosfwd:168:33: note: ‘std::fstream’
typedef basic_fstream<char> fstream;
^~~~~~~
ordenacao.cpp:16:5: error: ‘arquivo’ was not declared in this scope
arquivo.open("ordenar.txt");
^~~~~~~
ordenacao.cpp:20:9: error: ‘cout’ was not declared in this scope
cout << "Erro ao abrir arquivo." << endl;
^~~~
ordenacao.cpp:20:9: note: suggested alternative:
In file included from ordenacao.cpp:10:0:
/usr/include/c++/6/iostream:61:18: note: ‘std::cout’
extern ostream cout; /// Linked to standard output
^~~~
ordenacao.cpp:20:45: error: ‘endl’ was not declared in this scope
cout << "Erro ao abrir arquivo." << endl;
^~~~
ordenacao.cpp:20:45: note: suggested alternative:
In file included from /usr/include/c++/6/iostream:39:0,
from ordenacao.cpp:10:
/usr/include/c++/6/ostream:590:5: note: ‘std::endl’
endl(basic_ostream<_CharT, _Traits>& __os)
^~~~
ordenacao.cpp:26:9: error: ‘cout’ was not declared in this scope
cout << "Arquivo pronto para leitura." << endl;
^~~~
ordenacao.cpp:26:9: note: suggested alternative:
In file included from ordenacao.cpp:10:0:
/usr/include/c++/6/iostream:61:18: note: ‘std::cout’
extern ostream cout; /// Linked to standard output
^~~~
ordenacao.cpp:26:51: error: ‘endl’ was not declared in this scope
cout << "Arquivo pronto para leitura." << endl;
^~~~
ordenacao.cpp:26:51: note: suggested alternative:
In file included from /usr/include/c++/6/iostream:39:0,
from ordenacao.cpp:10:
/usr/include/c++/6/ostream:590:5: note: ‘std::endl’
endl(basic_ostream<_CharT, _Traits>& __os)
E aqui está o código:
#include <iostream>
#include <fstream>
int main(int agrc, char **argv)
{
fstream arquivo;
arquivo.open("ordenar.txt");