Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5372

Français • Re: gpio c++

$
0
0
donc , j'ai fais cela !

Code:

void ecritTemperature() {  ofstream fichier("temperatures.txt", ios::out | ios::trunc);  // on ouvre le fichier en lecture  if(fichier) { // si l'ouverture a réussi    float tempExtLue = ds_temperature[0];    float tempUnitExtLue = ds_temperature[1];    float tempEcExtLue = ds_temperature[2];    float tempUnitIntLue = ds_temperature[3];    float tempEcIntLue = ds_temperature[4];    fichier << "temperatureExtLue " << tempExtLue << endl;    fichier << "temperatureUnitExtLue " << tempUnitExtLue << endl;    fichier << "temperatureEcExtLue " << tempEcExtLue << endl;    fichier << "temperatureUnitIntLue " << tempUnitIntLue << endl;    fichier << "temperatureEcIntLue " << tempEcIntLue << endl;  } else {  // sinon    cerr << "Impossible d'ouvrir le fichier !" << endl;  }}void lectureTemperature() {  ifstream fichier("temperatures.txt", ios::in);  // on ouvre en lecture  if(fichier) {  // si l'ouverture a fonctionné    string ligne;  // déclaration d'une chaîne qui contiendra la ligne lue    while(getline(fichier, ligne)) {      cout << ligne << endl;  // on affiche la ligne    }  } else {    cerr << "Impossible d'ouvrir le fichier !" << endl;  }}

en sortie
temperatureExtLue 23.0625
temperatureUnitExtLue 22.875
temperatureEcExtLue 23.25
temperatureUnitIntLue 22.5
temperatureEcIntLue 23.0625

Statistics: Posted by ludoraspberry — Tue Feb 27, 2024 2:25 pm



Viewing all articles
Browse latest Browse all 5372

Trending Articles