Convertire un char vers mode_t en utilisant sscanf

lasmoum Messages postés 1 Date d'inscription samedi 7 mai 2011 Statut Membre Dernière intervention 1 avril 2011 - 1 avril 2011 à 04:40
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 - 1 avril 2011 à 10:53
bonne soirée,

j ai un problem avec la fonction sscanf quand je l'utilise avec les flag de compilation -Wall -W -Werror -ansi -pedantic.

je veux convertire une chaine de caractere a un mode_t et uid_t .....

c mon code :

char pathname[NAMSIZ];
mode_t mode;
uid_t uid;
gid_t gid;
off_t size;
time_t mtime;
struct utimbuf utbuf;
int checksum;


sscanf(header->name, "%s", pathname);
sscanf(header->mode, "%6ho ", &mode);
sscanf(header->uid, "%6ho ", &uid);
sscanf(header->gid, "%6ho ", &gid);
sscanf(header->size, "%11lo ", &size);
sscanf(header->mtime, "%11lo ", &mtime);
sscanf(header->chksum, "%6o", &checksum);

header c 'est une structure, tou les champ de cette structure sn de type char

les erreurs afficher :

untar_it.c: In function ‘untar_it’:
untar_it.c:77:3: error: format ‘%6ho’ expects type ‘short unsigned int *’, but argument 3 has type ‘mode_t *’
untar_it.c:78:3: error: format ‘%6ho’ expects type ‘short unsigned int *’, but argument 3 has type ‘uid_t *’
untar_it.c:79:3: error: format ‘%6ho’ expects type ‘short unsigned int *’, but argument 3 has type ‘gid_t *’
untar_it.c:80:3: error: format ‘%11lo’ expects type ‘long unsigned int *’, but argument 3 has type ‘off_t *’
untar_it.c:81:3: error: format ‘%11lo’ expects type ‘long unsigned int *’, but argument 3 has type ‘time_t *’
untar_it.c:82:3: error: format ‘%6o’ expects type ‘unsigned int *’, but argument 3 has type ‘int *’

PS : sans les flag ca marche tres bien, svp aidez moi vite svp encore merci.

1 réponse

cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
1 avril 2011 à 10:53
sscanf prend une chaine de caractère en premier argument. Je ne comprends donc pas ce que tu cherches à réaliser...

________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
0
Rejoignez-nous