Quick actions

cmd+k|ctrl+k

Navigation

Languages

Посмотреть каталоги линукса

Snippet info

Language

Cpp

Visibility

public

Author

sereja322

Created

2015-07-26T12:12:46Z

Updated

2015-07-26T12:21:27Z

#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;
}
INFO