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
|
string readuntil(FILE *file,char stop1,int JMAX)
{
char c1[60],c2[2],stop2[2]; //jai du ajouter un stop2 car en employant directement stop1 y'avait toujours une erreur avec strncomp
int j=0;
c1[0]='\0';
stop2[0]=stop1;
stop2[1]='\0';
printf("__%s--%d--\n",stop2,strncmp(stop2,c2,sizeof(stop1)));
while(fgets(c2,sizeof(c2),file))
{
if( !strncmp(stop2,c2,sizeof(stop1)) ) break;
strncat(c1,c2,sizeof(c1) );
if ( (1+j)>JMAX )
{
printf("you seems to have enter a wrong month in the file\n");
exit(-1);
};
c1[sizeof(c2)+(j++)]='\0';
};
//printf("__%s--%d--\n",stop2,strncmp(stop2,c2,sizeof(stop1)));
return c1;
}; |
Partager