• 2 odgovora
  • 2.812 pregleda
feof() daje TRUE? WHY? 25.05.2004. u 22:09 · pre 272 meseci #1
Imam sledeci problem. Napisao sam program koji treba da mi izbaci nepotrebne linkove iz fajla input_file i da ih upise u output_file. Posto sa komandom emerge -pvf some_package (koristim inace gentoo linux) dobijam gomilu adresa, a meni treba fajl bez duplirajucih adresa tako da kada zelim da negde na brzinu skinem sve te fajlove, da importujem linkove. Ali za while(feof(input_file)) dobijam nulu kao da je vec vpos_t postavljen na kraj fajla, a tek sam ga otvorio sa f-jom fopen(argv[argn-2], "r"). Inace prilazem kompletan source. Prilozio sam i fajl koji bi trebalo skratiti, ako zelite da isprobate program.
Potpis
Ken Thompson has an automobile which he helped design. Unlike most automobiles, it has neither speedometer, nor gas gauge, nor any of the other numerous idiot lights which plague the modern driver. Rather, if the driver makes a mistake, a giant “?” lights up in the center of the dashboard. “The experienced driver,” says Thompson, “will usually know what’s wrong.”
Re: feof() daje TRUE? WHY? 25.05.2004. u 22:13 · pre 272 meseci #2
Možda bi umesto toga što si zamislio mogao da probaš kombinaciju programa sort i uniq.

(man sort, man uniq)

Takođe mislim da petlja treba da glasi:

while (!feof(...)) iliti dok nije dosegnut kraj datoteke...

f
Re: feof() daje TRUE? WHY? 26.05.2004. u 08:53 · pre 272 meseci #3
Da pogresio sam kod feof, ali i kod pointera. Procitacu vise o njima pa nece biti vise zabune. Hvala ti na trudu.
Potpis
Ken Thompson has an automobile which he helped design. Unlike most automobiles, it has neither speedometer, nor gas gauge, nor any of the other numerous idiot lights which plague the modern driver. Rather, if the driver makes a mistake, a giant “?” lights up in the center of the dashboard. “The experienced driver,” says Thompson, “will usually know what’s wrong.”
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme