dacor
Messages postés40Date d'inscriptionmercredi 10 mai 2006StatutMembreDernière intervention 5 juin 2008
-
15 mai 2007 à 17:00
dacor
Messages postés40Date d'inscriptionmercredi 10 mai 2006StatutMembreDernière intervention 5 juin 2008
-
16 mai 2007 à 14:11
bonjour,
comment pourai je connaitre la taille d'un fichier en c++ sous linux( à partir de son nom ex : /home/user/file.txt ).
SAKingdom
Messages postés3212Date d'inscriptionlundi 7 novembre 2005StatutMembreDernière intervention16 février 200915 15 mai 2007 à 22:53
En C (stdlib)
FILE *file = fopen("nomfichier", "r");
fseek(file, 0, SEEK_END);
taille = ftell(file);
fseek(file, 0, SEEK_SET);
fclose(file);
En C++ (STL je crois), je crois que c'est:
ifstream file("nomfichier", ios::binary);
file.seekg(0, io_base::end);
taille = file.tellg();
file.seekg(0, io_base::beg);