Probléme Structure

Fermé
lirycs78 Messages postés 103 Date d'inscription vendredi 7 juillet 2006 Statut Membre Dernière intervention 7 janvier 2010 - 25 juin 2009 à 22:38
 TOTO901 - 26 juin 2009 à 13:35
Bonjour,

Voici mon code :
typedef struct argument argument;

struct argument{
char path[100];
char option[5];
};

int main(int argc, char **argv)
{
argument *ARG;

if(argc < 3){
puts("Entrez tous les arguments !");
puts("Exemple : ./prog <path> <option>");
exit(0);
}

ARG->path[100+1] = '\0';
ARG->option[5+1] = '\0';

ARG->path = argv[1];
ARG->option = argv[2];

printf("Path : %s\r\n",ARG->path);
printf("Option : %s\r\n",ARG->option);

getchar();
return(0);
}

Le probléme c'est qu'a la compilation j'ai deux erreurs :
|36|erreur: incompatible types in assignment|
|37|erreur: incompatible types in assignment|

Donc a ces 2 lignes
ARG->path = argv[1];
ARG->option = argv[2];

et je ne comprend pas pk :s help me please

1 réponse

Bonjour,

Tu pourrais essayer ceci :

strcpy( ARG->path, argv[1] );

(j'ai pas testé).
0