由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - ask a question about C
相关主题
Re: (I mean in java)Re: Help! Anyone have the experience extracting teServlet question: the orig filename
Re: how to write a string to a new file[转载] create gif/png image in C or java
Re: Need Emergent help for Java I/O!How to append something on a file?
ERROR!java.io.RandomAccessFile.readIntservlet programming 怪问题
pipe & filter 问题新手问个数学作图的问题?
新手求教 BufferedReader.readLine()How to write a file to the same directory of the class file?
几种流行的动态网页制作语言的比较help: where to download JAVA/swing? (转载)
Re: how to upload a local file to web server?how to open pipe files in java
相关话题的讨论汇总
话题: eof话题: char话题: functions话题: input话题: 0xff
进入Java版参与讨论
1 (共1页)
z********i
发帖数: 60
1
读数据从文件中,
input=fopen(filename,"rb");
while ( (c=fgetc(input)) != EOF )
{
}
可是数据中有0xff, 255(int)好像这个被当成eof了,请问有什末办法读出来吗?
f*****g
发帖数: 31
2

use fstat/stat to count your file's size. read
the size of byte instead of checking if EOF is reached.

【在 z********i 的大作中提到】
: 读数据从文件中,
: input=fopen(filename,"rb");
: while ( (c=fgetc(input)) != EOF )
: {
: }
: 可是数据中有0xff, 255(int)好像这个被当成eof了,请问有什末办法读出来吗?

g*******e
发帖数: 14
3
what is the type of c? int or char?
if char, you get into trouble because
-1 is same as 0xff in char.

【在 z********i 的大作中提到】
: 读数据从文件中,
: input=fopen(filename,"rb");
: while ( (c=fgetc(input)) != EOF )
: {
: }
: 可是数据中有0xff, 255(int)好像这个被当成eof了,请问有什末办法读出来吗?

s*****e
发帖数: 21415
4
agree, this code is wrong.

【在 g*******e 的大作中提到】
: what is the type of c? int or char?
: if char, you get into trouble because
: -1 is same as 0xff in char.

Q**g
发帖数: 183
5
what's the data type of variable c? if it's int, the code should be fine.
if it's char, you may get a problem coz you can not differentiate EOF
and 0xff. the following paragraph is extracted from GNU C library:
These functions return an int or wint_t value (for narrow and wide stream
functions respectively) that is either a character of input, or the special
value EOF/WEOF (usually -1). For the narrow stream functions it is
important to store the result of these functions in a variable of type i

【在 z********i 的大作中提到】
: 读数据从文件中,
: input=fopen(filename,"rb");
: while ( (c=fgetc(input)) != EOF )
: {
: }
: 可是数据中有0xff, 255(int)好像这个被当成eof了,请问有什末办法读出来吗?

z********i
发帖数: 60
6
Thank, already done with Java, will try later for C.
My former definition is
char c, changing to unsigned int c works. Thank you

【在 s*****e 的大作中提到】
: agree, this code is wrong.
b****k
发帖数: 10
7
while (!feof(input)) c=fgetc(input);

【在 z********i 的大作中提到】
: 读数据从文件中,
: input=fopen(filename,"rb");
: while ( (c=fgetc(input)) != EOF )
: {
: }
: 可是数据中有0xff, 255(int)好像这个被当成eof了,请问有什末办法读出来吗?

1 (共1页)
进入Java版参与讨论
相关主题
how to open pipe files in javapipe & filter 问题
Linux下安装一个Java软件出现异常新手求教 BufferedReader.readLine()
问个关于版权的问题几种流行的动态网页制作语言的比较
急问如何append double 数据到txt文件Re: how to upload a local file to web server?
Re: (I mean in java)Re: Help! Anyone have the experience extracting teServlet question: the orig filename
Re: how to write a string to a new file[转载] create gif/png image in C or java
Re: Need Emergent help for Java I/O!How to append something on a file?
ERROR!java.io.RandomAccessFile.readIntservlet programming 怪问题
相关话题的讨论汇总
话题: eof话题: char话题: functions话题: input话题: 0xff