extraits de mon code arrangés pour faire un exemple générique (je suppose que les données à dumper sont dans un tableau global qui s'appelle data) :
int main (int argc, char **argv) {
int calctype = -1;
char nomfic_onti[9] = "fichier";
char nomfic_onpc[13];
FILE *fichier_arrivee;
unsigned char *out_buffer;
unsigned int taille_resultat;
if (argc >= 2) {
if (!strcmp ("-89", argv[1])) calctype = 0;
else if (!strcmp ("-92", argv[1])) calctype = 1;
}
if (calctype < 0) {
printf ("Generate files for which calculator ? 0 : TI-89 -- 1 : TI-92+\n> ");
while (!scanf ("%d", &calctype) || (calctype && calctype != 1))
printf ("Please type 0 for TI-89 or 1 for TI-92+ ; Ctrl-C to cancel.\n> ");
}
out_buffer = DataBuffer2OTHBuffer (calctype, "dossier", nomfic_onti, "TRUC", sizeof(data), data, &taille_resultat);
if (!taille_resultat) {
fprintf (stderr, "Error processing data\n");
return 1;
}
sprintf (nomfic_onpc, "%s%s", nomfic_onti, calctype ? ".9xy" : ".89y");
fichier_arrivee = fopen (nomfic_onpc, "wb");
if (!fichier_arrivee) {
fprintf (stderr, "Error opening file %s\n", nomfic_onpc);
free (out_buffer);
return 1;
}
if (fwrite (out_buffer, taille_resultat, 1, fichier_arrivee) != 1) {
fclose (fichier_arrivee);
free (out_buffer);
fprintf (stderr, "Error writing data\n")
return 1;
}
free (out_buffer);
fclose (fichier_arrivee);
return 0;
}