May 28, 2014 at 2:20pm UTC
Hi i have two directories (for windows readed from file so i can add more or less then i want too) data_install data_main. Each has different number of random files (text image and etc.). And i want to create simple engine to count files and store which directory has what files and id number for each file in directory(store in data_w.txt file). Example:
data_install
1. data_1.txt
2. data_2.txt
3. image_1.jpg
4. image_2.png
data_main
1. data_3.txt
2. data_4.txt
3. image_1.jpg
4. image_2.png
and i'm using Microsoft visual studio if that changes anything
heres my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#include <stdio.h>
#include <windows.h>
#include <fstream>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <cassert>
#include <vector>
//-------------------------------------------------------------------------------------
using namespace std;
//-------------------------------------------------------------------------------------
const int max_lengh = 1000;
const char DR[] = "data_r.txt" ;
const char DW[] = "data_w.txt" ;
//-------------------------------------------------------------------------------------
struct file
{
string name;
int id;
};
//-------------------------------------------------------------------------------------
string file[max_lengh];
string dir[max_lengh];
//-------------------------------------------------------------------------------------
void move(int file[], int n);
void count_files(int n);
void read(const char DR[], int & n);
//-------------------------------------------------------------------------------------
int main()
{
return 0;
}
void read(const char DR[], int & n)
{
int i;
ifstream read(DR);
read >> n;
for (i = 0; i < n; i++)
{
read >> dir[i];
//cout << i;
}
read.close();
}
void count_files(int n)
{
int i;
for (i = 0; i < n; i++)
{
count
}
}
File to store what directories to open.
data_r.txt
1 2 3
2
data_install
data_main
Last edited on May 28, 2014 at 2:21pm UTC
May 28, 2014 at 7:13pm UTC
FindFirstFile and FindNextFile does anyone know how to properlly use it ? And explain or write simple program which this which i could study.