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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
void Default_Config()
{
fstream fichier("default config.txt", ios::out | ios::trunc);
if (fichier)
{
for (int i = 0; i < 15; i++)
{
int a = 5; // c'est valeur juste pour tester
a = a*i;
fichier << a << endl;
}
fichier.close();
}
else
cerr << "Impossible d'ouvrir le fichier !" << endl;
}
void new_config()
{
fstream fichier("new config", ios::out | ios::trunc);
if (fichier)
{
for (int i = 0; i < 15; i++)
{
int a = 6;
a = a*i;
fichier << a << endl;
}
fichier.close();
}
else
cerr << "Impossible d'ouvrir le fichier !" << endl;
}
std::string fichiers_identiques_strcmp(string fichier1, string fichier2)
{
std::string a = "";
int position = 0;
char str1[256];
char str2[256];
fstream file1(fichier1, ios::in);
fstream file2(fichier2, ios::in);
if (!file1 || !file2)
{
perror("Impossible d'ouvrir les fichiers");
exit(1);
}
while (file1 >> str1 && file2 >> str2)
{
position++;
if (strcmp(str1, str2) != 0)
{
a +=str2;
}
}
file1.close();
file2.close();
return a;
}
int main()
{
string fiche1 = "default config.txt";
string fiche2 = "new config.txt";
/*fstream file(fiche1, ios::out);*/
std::string c;
int b;
Default_Config();
Default_Config1();
if (lineNumber(fiche1) == lineNumber(fiche2))
{
c = fichiers_identiques_strcmp("default config.txt", "new config.txt");
/*return a;*/
}
/*else c = false;*/
b = lineNumber(fiche1);
string s;
fstream file;
file.open(fiche1, ios::out);
file << "" << endl;
file.close();
return 0;
} |