Petit prob de passage par pointeur
Bonjour,
Voila j'ai deux petits problemes :
a la compil :
test.c:14: attention : passing argument 1 of «time» from incompatible pointer type
a l'execution, ca affiche rien ! a part les -- , surement que mon bound est mal passé a la fonction et mal modifier.
Voici le code :
Code:
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
|
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
/* Fonction qui permet de passer un boundary */
int genererBoundary(char *tab){
time_t now;
int taille;
struct tm now_here;
char *entete="boundary=";
now=time(&now_here);
taille=strlen(entete)+10;
tab=malloc(sizeof(char)*(taille+1));
if(!tab) {
fprintf(stderr,"--erreur de generation de boundary--\n");
return -1;
}
snprintf(tab,taille,"%s%10d",entete,now);
return 0;
}
/* Generer un boundary */
int main (int argc, char* argv[]){
char *bound;
genererBoundary(bound);
fprintf(stdout,"--%s\n",bound);
} |
Sinon, si vous avez d'autres remarques sur mon code, n'hesitez car he debute et je dois surement coder desfois un peu "sale", genre eviter le +10 qui correspond au nombre de caractere dans la var now que je veux afficher.
Ciao,