[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: chop LF



>From the tone of the post I suspect a shell command would be more useful

cat foo | tr -d "0A" | a.out
	this will strip out that character from your input stream every time, or

cat foo | tr -d "0A" > foo2
	this will create foo2 without the 0A character (don't use foo as input and output at the same time)

or the best way is to modify your source to deal correctly with the 0a problem - perhaps its a bonus mark in disguise :)

----------
From: 	Oswald Buddenhagen[SMTP:ob6@inf.tu-dresden.de]
Sent: 	Saturday, 22 April 2000 5:40 AM
To: 	maths
Cc: 	debian-user
Subject: 	Re: chop LF

> the problem is foo is end in "LF" ( 0A ), and it will let a.out
> get wrong output. if i run
> 
> #a.out
> 
> and input data from keybord, then end it by ctrl+D, will get the
> right answer.
> 
i'm not sure, if i understand you right ... you are having trouble to
detect the end of file, when there is an empty line at it's end, right?

i didn't test it, but this should be the default way of doing it:

FILE *fd;
char buf[1000];

while(!feof(fd)) {
  fgets(buf,sizeof(buf),fd);
}

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Linux - the last service pack you'll ever need.


-- 
Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null



Reply to: