Parser un fichier conf
# commentaire
nom = Joe
tracker = bxdomain.bxm
script=/etc/usr/con.php
#include <stdio.h>
#include <string.h>
int main()
{
FILE * pFile;
char str[73], *st[5], *pch;
int c=0;
pFile = fopen ("cfg.conf","r");
if (pFile == NULL) perror ("Error opening file");
else {
while (!feof(pFile)) {
fgets (str,73,pFile);
if (str[0] != '#') { // si ce n'est pas un commentaire
pch = strtok(str,"="); //splitte
if (pch != NULL){
st[c]=pch;
printf("var: %s\n",pch);
pch = strtok (NULL,"\n");
printf("VAL: %s\n\n",pch);
c++;
}
}
}
fclose (pFile); free(str); free(st); free(pch);
}
//for (c=0;c<=nbvars;c++) printf("st[%i] = %s\n",c,st[c]);
getchar();
return 0;
}