context of a C program reading from a file?
I know its end of file but ...not sure?
|
|
0
|
|
|
|
Reply
|
FW3006 (25)
|
4/8/2008 6:00:40 AM |
|
2005 wrote:
> context of a C program reading from a file?
Please don't ask your real question in the subject line.
FEOF is not mentioned in the C standard.
> I know its end of file but ...not sure?
Get yourself a decent C text book. C is not a good
language to learn by asking 20 (000) questions.
--
Peter
|
|
0
|
|
|
|
Reply
|
airia (1802)
|
4/8/2008 6:06:31 AM
|
|
On Apr 7, 11:06 pm, Peter Nilsson <ai...@acay.com.au> wrote:
> 2005 wrote:
> > context of a C program reading from a file?
>
> Please don't ask your real question in the subject line.
>
> FEOF is not mentioned in the C standard.
>
> > I know its end of file but ...not sure?
>
> Get yourself a decent C text book. C is not a good
> language to learn by asking 20 (000) questions.
>
> --
> Peter
I do have several books - I saw a code online with EOF when reading
from a file.
That's why
I read the book too but would like a crisp answer
I appreciate a tip.
|
|
0
|
|
|
|
Reply
|
FW3006 (25)
|
4/8/2008 6:11:18 AM
|
|
2005 said:
<snip>
> I do have several books - I saw a code online with EOF when reading
> from a file.
> That's why
>
> I read the book too but would like a crisp answer
K&R2 provides a crisp answer on page 16.
> I appreciate a tip.
Here's a tip, then: read more.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
|
|
0
|
|
|
|
Reply
|
rjh (10789)
|
4/8/2008 6:47:13 AM
|
|
On Apr 7, 11:47 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> 2005 said:
>
> <snip>
>
> > I do have several books - I saw a code online with EOF when reading
> > from a file.
> > That's why
>
> > I read the book too but would like a crisp answer
>
> K&R2 provides a crisp answer on page 16.
>
I have K&R - not sure if there had been a "2"
EOF - a distinctive value when there is no more input, a value that
cannot be confused with any real character. This value is called
EOF, for ``end of file''.
FILE *in = fopen("myfile.txt", "r"); // Open myfile.txt read-only
while((myChar=fgetc(in)) != EOF) {
---------
---
feof is to distinguish between cases where a stream operation has
reached the end of a file and cases where the "EOF" (End Of File)
error message has simply been returned as a default error message,
without the end of the file actually being reached.
while(!feof(my_file)) {
/* [...End of file not reached, do something with it...] */
}
-----
--
So what is the difference when it comes to application?
|
|
0
|
|
|
|
Reply
|
FW3006 (25)
|
4/8/2008 7:00:28 AM
|
|
2005 said:
<snip>
> while(!feof(my_file)) {
> /* [...End of file not reached, do something with it...] */
I sometimes despair of humanity.
while(file-reading-function doesn't
return an indication that data
could not be read - which may
well involve EOF, e.g. for
getchar, getc, fgetc)
{
process the data;
}
if(feof(my_file)
{
all the data was processed;
}
else
{
there seems to have been an input error - so check ferror()'s result.
}
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
|
|
0
|
|
|
|
Reply
|
rjh (10789)
|
4/8/2008 7:20:52 AM
|
|
2005 wrote:
> I have K&R - not sure if there had been a "2"
>
> EOF - a distinctive value when there is no more input, a value that
> cannot be confused with any real character. This value is called
> EOF, for ``end of file''.
> FILE *in = fopen("myfile.txt", "r"); // Open myfile.txt read-only
> while((myChar=fgetc(in)) != EOF) {
> ---------
> ---
>
> feof is to distinguish between cases where a stream operation has
> reached the end of a file and cases where the "EOF" (End Of File)
> error message has simply been returned as a default error message,
> without the end of the file actually being reached.
>
> while(!feof(my_file)) {
> /* [...End of file not reached, do something with it...] */
> }
> -----
> --
>
> So what is the difference when it comes to application?
What do *you* think the difference is? Post your answer here, and we
will tell you if you are right or not, and if you are wrong, we will
tell you where your mistake is.
I suggest this for two reasons:
1) It is *much* more effective to learn by doing than by being lectured.
2) It's difficult to see which bit is confusing you. You have already
asked the difference between feof() and EOF, and Richard gave you this
answer. If you just ask the same question again, we don't know how to
make it any clearer.
Philip
|
|
0
|
|
|
|
Reply
|
pgp (246)
|
4/8/2008 7:51:03 AM
|
|
2005 <FW3006@sbcglobal.net> writes:
> On Apr 7, 11:47 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> 2005 said:
>>
>> <snip>
>>
>> > I do have several books - I saw a code online with EOF when reading
>> > from a file.
>> > That's why
>>
>> > I read the book too but would like a crisp answer
>>
>> K&R2 provides a crisp answer on page 16.
>>
> I have K&R - not sure if there had been a "2"
K&R2 is the second edition. The first edition is mostly of historical
interest; it describes a largely obsolete version of the language. If
you have the first edition, invest in a copy of the second.
> EOF
[snip]
> feof is to
[snip]
> So what is the difference when it comes to application?
The comp.lang.c FAQ is at http://www.c-faq.com. Read section 12.
Then read the rest of it.
--
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|
|
0
|
|
|
|
Reply
|
kst-u (21469)
|
4/8/2008 7:52:07 AM
|
|
2005 wrote:
> Peter Nilsson <ai...@acay.com.au> wrote:
>> 2005 wrote:
>>
>>> context of a C program reading from a file?
>>>
>> Please don't ask your real question in the subject line.
>>
>> FEOF is not mentioned in the C standard.
>>
>>> I know its end of file but ...not sure?
>>
>> Get yourself a decent C text book. C is not a good
>> language to learn by asking 20 (000) questions.
>
> I do have several books - I saw a code online with EOF when
> reading from a file.
Get yourself K&R2. Use it as the ultimate authority, barring the
actual C standard. Burn any books written by Herbert Schildt.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
|
|
0
|
|
|
|
Reply
|
cbfalconer (19183)
|
4/8/2008 10:10:47 PM
|
|
On Tue, 08 Apr 2008 00:52:07 -0700, Keith Thompson <kst-u@mib.org>
wrote:
> 2005 <FW3006@sbcglobal.net> writes:
> > I have K&R - not sure if there had been a "2"
>
> K&R2 is the second edition. The first edition is mostly of historical
> interest; it describes a largely obsolete version of the language. If
> you have the first edition, invest in a copy of the second.
>
Which you might be able to finance by selling K&R1 to a collector. <G>
And get the errata at http://cm.bell-labs.com/cm/cs/cbook/2ediffs.html
- formerly david.thompson1 || achar(64) || worldnet.att.net
|
|
0
|
|
|
|
Reply
|
dave.thompson2 (767)
|
4/21/2008 1:33:45 AM
|
|
|
9 Replies
164 Views
(page loaded in 0.203 seconds)
Similiar Articles: GWT Designer and Window Builder - comp.lang.java.programmer ...What are the differences between the two instruments? Thank you very much! ... install ncurses gem on windows - comp ... dll/mexw32 file from matlab - Stack Overflow ... The difference between return and exit()? - comp.unix.programmer ...c - difference between exit and return - Stack Overflow In C, there's not much difference when used in the startup function of the program (which can be main(), wmain ... While loops - comp.soft-sys.matlabfeof() cannot predict EOF because more data might be added to the file or socket or serial port while the program is waiting (or busy), so feof() is restricted to ... /usr/local/bin/stty: not found - comp.lang.tcldifferences between /bin, /usr/bin and /usr/local/bin - comp.unix ... Hello, What are the ... problem with expect eof - The UNIX and Linux Forums spawn passwd exptest sh: /usr ... Re: LEA instruction - comp.lang.asm.x86... set - CMP - comp.lang.asm.x86 About instruction lea - comp.lang.asm.x86 x86 Instruction set - CMP - comp.lang.asm.x86 ... x86 CMP Instruction Difference - Stack Overflow ... what's the differ between lea and mov offset ? - comp.lang.asm.x86 ...Greetings all, a beginner is here ! :) I want to know what's the difference between using : 1- lea dx,string 2- mov dx,offset string I'm confused... Zip data descriptor (bit 3 flag) - comp.compressionWhen writing: The stream (or pipe) is read until EOF is reached. At that point ... When found, if the compressed size justifies the difference between two offsets, the 12 ... Tomcat 32 bits vs Tomcat 64 bits - comp.lang.java.programmer ...Java doesn't care; the differences are subsumed in the JVMs. Bytecode is bytecode. ... Stack Overflow... faster with the 64-bit version vs the 32-bit. Either ... Can current ... Carriage return in strings - comp.unix.programmercount=$(wc -l << EOF $vcdiffout EOF ) if [ "$((count))" -eq 0 ]; then echo NO CVS DIFFERENCE else cat << EOF $vcdiffout EOF But actually, the whole script can be ... Question with linking program with ATI opengl library - comp ...My assumption about the performance difference is that, ati linux driver directly ... cuda - Linking to the NVIDIA OpenGL library - Stack Overflow I'm trying to properly run ... feof ....EOF - C BoardI was just wandering what the difference between EOF and feof is. the only thing i know is that in my code EOF gives errors like cannot convertchar to EOF vs. feof() and ferror() - C / C++end-of-file. feof() won't return true until *after* you've tried to read beyond ... What are the differences in EOF & FEOF in the; feof(), fseek(), fread() question about gets ... 7/17/2012 8:10:52 AM
|