C语言指针问题,求详解!!
设fp为指向某二进制文件的指针,且已读到此文件末尾,则函数feof(fp)的返回值为A.EOFBB.非0值C.0D.NULL...
设fp为指向某二进制文件的指针,且已读到此文件末尾,则函数feof(fp)的返回值为
A.EOFB B.非0值 C.0 D.NULL 展开
A.EOFB B.非0值 C.0 D.NULL 展开
5个回答
展开全部
feofSee Alsoclearerr
| ferror
Requirements
OS Versions: Windows CE 2.0 and later.
Header:
stdlib.h.
Link Library: coredll.dll.
Tests for end-of-file on a stream.
int feof( FILE* stream
);Parametersstream
Pointer to FILE structure. Return Values
The feof function returns a nonzero value after the first read
operation that attempts to read past the end of the file.
It returns 0 if the current position is not end of file.
There is no error return.
Remarks
The feof routine (implemented both as a function and as a macro)
determines whether the end of stream has been reached.
When end of file is reached, read operations return an end-of-file indicator
until the stream is closed or until fsetpos, fseek, or
clearerr is called against it.
Example
/* FEOF.C: This program uses feof to indicate when
* it reaches the end of the file FEOF.C. It also
* checks for errors with ferror.
*/
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
int count, total = 0;
char buffer[100];
FILE *stream;
if( (stream = fopen( "feof.c", "r" )) == NULL )
exit( 1 );
/* Cycle until end of file reached: */
while( !feof( stream ) )
{
/* Attempt to read in 10 bytes: */
count = fread( buffer, sizeof( char ), 100, stream );
if( ferror( stream ) ) {
printf( "Read error" );
break;
}
/* Total up actual bytes read */
total += count;
}
printf( "Number of bytes read = %d\n", total );
fclose( stream );
}
Output
Number of bytes read = 745Requirements
OS Versions: Windows CE 2.0 and later.
Header:
stdlib.h.
Link Library: coredll.dll.
See Also
clearerr | ferror
Last updated on Wednesday, September 14, 2005
© 2005
Microsoft Corporation. All rights reserved.
| ferror
Requirements
OS Versions: Windows CE 2.0 and later.
Header:
stdlib.h.
Link Library: coredll.dll.
Tests for end-of-file on a stream.
int feof( FILE* stream
);Parametersstream
Pointer to FILE structure. Return Values
The feof function returns a nonzero value after the first read
operation that attempts to read past the end of the file.
It returns 0 if the current position is not end of file.
There is no error return.
Remarks
The feof routine (implemented both as a function and as a macro)
determines whether the end of stream has been reached.
When end of file is reached, read operations return an end-of-file indicator
until the stream is closed or until fsetpos, fseek, or
clearerr is called against it.
Example
/* FEOF.C: This program uses feof to indicate when
* it reaches the end of the file FEOF.C. It also
* checks for errors with ferror.
*/
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
int count, total = 0;
char buffer[100];
FILE *stream;
if( (stream = fopen( "feof.c", "r" )) == NULL )
exit( 1 );
/* Cycle until end of file reached: */
while( !feof( stream ) )
{
/* Attempt to read in 10 bytes: */
count = fread( buffer, sizeof( char ), 100, stream );
if( ferror( stream ) ) {
printf( "Read error" );
break;
}
/* Total up actual bytes read */
total += count;
}
printf( "Number of bytes read = %d\n", total );
fclose( stream );
}
Output
Number of bytes read = 745Requirements
OS Versions: Windows CE 2.0 and later.
Header:
stdlib.h.
Link Library: coredll.dll.
See Also
clearerr | ferror
Last updated on Wednesday, September 14, 2005
© 2005
Microsoft Corporation. All rights reserved.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
B.
feof 就是检测 当前fp打开的文件 指针是否在文件的最后面。到了结尾肯定返回非0
feof 就是检测 当前fp打开的文件 指针是否在文件的最后面。到了结尾肯定返回非0
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
B
如果到了文件尾,表明是,返回非零
如果到了文件尾,表明是,返回非零
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
30分钟彻底学会C语言指针
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询