#include <iostream>
#include <stdio.h>
#include <dirent.h>
#include <string>
#include <fstream>
using namespace std;
int main() {
DIR *dfd;
struct dirent *dp;
string filename("."); // путь . .. ../.. и т.д
cout << " >>" << filename << endl;
dfd=opendir(filename.data());
while( (dp=readdir(dfd)) != NULL )
{
cout << dp->d_ino << "\t";
cout << dp->d_name << endl;
}
closedir(dfd);
cout << endl;
ofstream fout("main.cpp"); // пишем в файл
fout << "1";
fout.close();
char chardata[512][256];
ifstream fin("main.cpp"); // читаем из файла
int i = 0;
if(fin.is_open())
{
for(; !fin.eof() && i < 512; i++)
{
fin.getline(chardata[i],255,'\n');
//fin.read(chardata,50);
}
fin.close();
} else cout << "ошибка открытия файла"<<endl;
for(int q = 0; q < i; q++)
cout << chardata[q] << endl;
return 0;
}