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
| #include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fichierEntree ("fichier.test", ios::binary);
if (fichierEntree.is_open())
{
unsigned int nombreFlt = 0;
float flottant = 0;
fichierEntree.read(reinterpret_cast<char*> (&nombreFlt), 2);
cout << nombreFlt << " flottant";
if (nombreFlt > 1) {cout << "s";}
cout << " au total\n" << endl;
for (long i = 0 ; i < nombreFlt ; i++)
{
fichierEntree.read(reinterpret_cast<char*> (&flottant), 4);
cout << (i + 1) << "\t" << flottant << endl;
}
cout << endl;
fichierEntree.close();
}
else
{
cout << "Fichier introuvable !" << endl;
}
system("pause");
return 0;
} |