To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 14529
14528  |  14530
Subject: 
Re: how does a line ends?
Newsgroups: 
lugnet.cad
Date: 
Sat, 7 Apr 2007 22:31:32 GMT
Viewed: 
1665 times
  
In lugnet.cad, Chris Phillips wrote:
   In lugnet.cad, Travis Cobbs wrote:
   OK, as promised, here it my fgets replacement:

That was quick! Thanks for taking the time to indulge me...

  
char *myFgets(char *buf, int bufSize, FILE *file)
{
    int i;

    for (i = 0; i < bufSize - 1; i++)
    {
        int char1 = fgetc(file);

        if (feof(file))

   It is interesting that it was that much time difference. Are these the total load times, or just profiling of the time spent inside the fgets() routines? I see one or two things you might tighten up in this code, but nothing that’s going to make it 50% faster.

Quick question. I was in a hurry, and wanted to play it safe, so I call feof instead of checking to see if char1 == EOF. Any idea what gets returned for extended ASCII characters (>= 128)? Does the int contain positive numbers greater than 128, or are they in the range [-128, 127]? If they’re all positive, the char1 == EOF is a safe check. If not, it isn’t.

--Travis



Message is in Reply To:
  Re: how does a line ends?
 
(...) That was quick! Thanks for taking the time to indulge me... (...) It is interesting that it was that much time difference. Are these the total load times, or just profiling of the time spent inside the fgets() routines? I see one or two things (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)

24 Messages in This Thread:











Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR