Réponse acceptée !
Salut.
strchr et strdup sont tes amies.
Par exemple (un peu testé):
Code C/C++ :
struct info {
char * nom;
char * origine;
char * usage;
};
void
parse_info(char * line, struct info * inf)
{
char * tab = strchr(line, '\t');
if (tab == NULL)
goto err_nom;
*tab = 0;
inf->nom = strdup(line);
line = tab + 1;
tab = strchr(line, '\t');
if (tab == NULL)
goto err_origine;
*tab = 0;
inf->origine = strdup(line);
line = tab + 1;
inf->usage = strdup(line);
return;
err_nom:
inf->nom = strdup("");
err_origine:
inf->origine = strdup("");
inf->usage = strdup("");
}
Bonne prog,
--
Chouchou.