delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/17/07:28:55

Date: Sat, 17 Mar 2001 17:41:27 +0530 (IST)
From: Mridul Muralidharan <ec97027 AT matrix DOT reccal DOT ernet DOT in>
To: sager+@andrew.cmu.edu
cc: Djgpp mailing list <djgpp AT delorie DOT com>
Subject: Re: Attempting to make an auto indenter
In-Reply-To: <guglJAq00UjGEqYEcz@andrew.cmu.edu>
Message-ID: <Pine.LNX.4.04.10103171737250.3950-100000@matrix.reccal.ernet.in>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sat, 17 Mar 2001, James W Sager Iii wrote:
[snip]
> I can't even get my program to read in a line without getting extra
> Ascii gibberish.  Anyone have the code to read in a line of text out of
> an Ascii text file?  My code looks like this:
> 
[snip]
> char *getline(FILE *f1)
> {
> //Assumes no line is greater than 256 characters
> char c=0;
> char line[256];
> int i;
> //Loop while not end of line
> i=0;
> while(c!=10)
> {
>   c=fgetc(f1);
>    if(c!=10)
>    line[i]=c;
>    i++;
> }
>    line[i]='\0';
> return(line);
> }

  here ,you are returning a local variable (array line)of function
getline() function. use -Wall option in u'r gcc command line to get
warnings like these reported.

hope u finish u'r indent ( i may need it too ! )

Mridul Muralidharan
S8 Electronics and Communication
Regional Engineering College
Calicut
India

------------------------------------------------------------------------------

If the code and the comments disagree, then both are probably wrong.
                -- Norm Schryer

All generalizations are false, including this one.
                -- Mark Twain

/earth is 98% full ... please delete anyone you can.

        - fortune


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019