Kod:
#include <iostream>
#include <fstream>
using namespace std;
void citaj()
{
ifstream fajl1;
string blaa;
fajl1.open("fajl.txt");
if(!fajl1) {
cout << "file could not be opened";
exit(1);
}
fajl1 >> blaa;
while (!fajl1.eof())
{
cout << blaa<<"\n";
fajl1>> blaa;
}
fajl1.close();
}
int main()
{
ofstream fajl;
int i;
int bla[2][5]={{1,2,3,4,5},{6,7,8,9,10}};
fajl.open("fajl.txt");
if( !fajl ) {
cout << "file could not be opened" << endl;
exit(1);
}
for (i=0; i<2; i++)
{
for(int a=0;a<5;a++)
{
fajl << "Niz "<<i<<" "<<bla[i][a]<<endl;
}
}
fajl.close();
citaj();
}