Mail Archives: djgpp/2001/03/17/07:28:55
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 -