Création d'un format pour récupèrer des informations
Bonjour,
je souhaite ecrire dans un fichier , la date d'execution et de fin d'execution du fichier ( j'y arrive), mais a présent je souhaite créer un propre format afin de pouvoir parser ce fichier à l'aide d'un script python plus tard.
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
|
#include <iostream>
#include <string>
#include <fstream>
#include <ctime>
using namespace std;
void ecrireDansFichier(fstream& fichier) {
if(fichier)
{
string nom = "Peter";
fichier << "Bonjour, " << nom << endl;
std::time_t result = std::time(NULL);
fichier << __DATE__ << ":" << __TIME__ << "/n";
fichier << std::asctime(std::localtime(&result)) << std::endl;
fichier.close();
}
else
cerr << "Impossible d'ouvrir le fichier" << endl;
int main(){
fstream fichier("trace.log", ios::out | ios::trunc);
ecrireDansFichier(fichier);
return 0;
} |