Réponse acceptée !
int CreateFileOnHardDisk (unsigned char * FILE_BUF,int size,int _toi)
{
FILE *stream;
char FileName[30];
int result;
struct _stat buff;
sprintf( FileName,"TmP%d", _toi );
if(_toi==0)
sprintf(FileName,"fdt%d.txt",fdtnum);
result = _stat( FileName , &buff );
while( result == 0 )
{
if(_toi==0)
{
fdtnum++;
sprintf( FileName,"TmP%d.txt", fdtnum );
}
else
{
sprintf( FileName,"verifytheTOI%d", _toi );
}
result = _stat( FileName , &buff );
}
if(result!=0)
{
if( (stream = fopen(FileName, "w+" )) == NULL )
printf( "The file %s was not opened\n", FileName );
else
{
if(fwrite(FILE_BUF,size,1,stream)==0)
{
printf ("\nproblem with file");
return (-1);
}
else
{
printf("\nfile: %s ,created!",FileName);
if(_toi==0)
fdtnum++;
}
}
}
if( fclose( stream ) )
printf( "The file %s was not closed\n",FileName);
return 0;
}
le toi est juste un indicateur pour le nom du fichier:)

YA² : Hakuna Mahatma
