RE:Use of fgets () Re: use of library funct

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Sun Nov 28 1999 - 03:11:22 MET


Hello,

Because \n and cr-lf characters may have been changed during e-mail
transaction, I can not reproduce your problem. But I guess
you need to check *tmp against 0 before assignment. And in this
context, strchr would be better than strrchr.

  ctmp = strchr(Line[i],'\n');
  if(ctmp) *ctmp = 0;

Thank you
Masaharu Goto

>Hello,
>
>I just found that the code works with old text files but not with the 
>new ones.
>The code:
>
>char Line[4][200], *ctmp;
>Int_t i
>.
>.
>.
>    for (i=0;i<4;i++)  // i<6 reduced to i<4 since 
>    {                  // only for lines with data for each event
>       fgets (Line[i], 199, fin);
>       printf ("%d: /%s/\n", i, Line[i]);
>       ctmp = strrchr (Line[i], '\n');
>       *ctmp = 0;
>    }
>
>
>file 1 (working)
>



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:43 MET