Probléme Structure

lirycs78 Messages postés 106 Statut Membre -  
 TOTO901 -
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

TOTO901
 
Bonjour,

Tu pourrais essayer ceci :

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

(j'ai pas testé).
0