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
| BOOL bexport = TRUE;
int i = 0, m = 1, n = 1, FileSize = 0;
int T[128][128];
char chaine[10];
char pathFile[MAX_PATH];
char *ligne;
char *pTk;
char errorTxt[512];
FILE *hFile;
//clear mémoire tableau
memset(*T, 0, sizeof(T));
// ouverture du fichier en lecture seul
sprintf(pathFile, ".\\MATFID.csv");
if(hFile = fopen(pathFile, "rb"))
{
// taille du fichier
FileSize = RetFileLength(hFile) - 1;
if(FileSize > 0)
{
// recup du contenu du fichier
ligne = new char[FileSize + 1];
ligne[0]='\0';
if(fread(ligne,1,FileSize,hFile))
{
if(ligne[0] != '\0')
{
// séparation des reqêtes
ligne[FileSize]='\0';
pTk = strtok (ligne,"\n");
while (pTk != NULL && bexport)
{
for(i=0; i < 127; i++)
{
if(pTk[i] != '\n')
{
if(pTk[i] != ';')
{
sprintf(chaine,"%d",T[m][n]);
T[m][n]=strcat(chaine,pTk[i]);
}
else
m++;
}
else
{
m=1;
n++;
}
}
}
}
else
{
...
}
}
...
delete ligne;
}
fclose(hFile);
}
... |
Partager