从文件中读取问题 [英] Problems reading from files

查看:82
本文介绍了从文件中读取问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在从文件中读取程序。


我有一个文本文件files.txt其中包含要打开的文件的名称,即
的文件名,即files.txt的内容是


Homo_sapiens.fa

Rattus_norvegicus.fa


(它们是可以在任何文本编辑器中打开的FA文件。)


每个FA文件都包含一个数字在第一行和一个字符串

的字符(A,T,G或C)。例如,Homo_sapiens.fa文件

将包含


16571

GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT TTGGTATTTT

CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGC ACCCTATGTC

GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTAC GTTCAATATT

ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGA CATAATAATA

等等,16571 A,T,G或Cs。


以下是我的代码:


#include< stdio.h>

#include< stdlib.h>


#define MAX_FILE 100 //文件名最大长度

#define MAX_SEQ 20000 //最大序列长度

#定义N 2 //序列总数


int main(无效)

{

FILE * fin,* fin1, * fout;

char输入[MAX_FILE + 1],seq [N] [MAX_SEQ + 1],c;

int size [N],i = 0,j = 0;


fin = fopen(" files.txt"," r");

fout = fopen(" output.txt"," w");

while(fscanf(fin,"%s",input)!= EOF)

{

fin1 = fopen(输入," r");

printf("%s \ n",输入);

fscanf(fin1,"%d",& size [i]);

printf("%d \ n",size [i]);

while((c = fgetc(fin1))!= EOF)

{

fprintf(fout,"%c",c);

if(c!=''\ n'')

seq [i] [j] = c;

j ++;

if(j%100 == 0)

printf("%c",seq [i] [j]);

}

fprintf(fout," \ n\ n");

j = 0;

i ++;

}


fclose(fin);

fclose(fin1);

fclose(fout);

返回0;

}


printf语句让我查看我的代码。


当我尝试打开2个文件,第一个文件读得很好,但

第二个文件是inc omplete。超过600个字符无法读取,

程序挂起。


我得到输出(由于检查printf语句)


Homo_sapiens.fa

16571

Rattus_norvegicus.fa

16300

< program hangs> ;


请注意语句

if(j%100 == 0)

printf("%c", seq [i] [j]);

没有被执行,但是如果我只是打印字符seq [0] [100],那么

就会正确显示。


如果我尝试打开3个文件,会发生相同的程序,即第一个

文件被正确读取,但第二个文件不完整且

根本没有读取第三个文件。我得到了输出


Homo_sapiens.fa

16571

Rattus_norvegicus.fa

16300

Homo_sapiens.fa

16571

分段错误


我用2个小得多的文件尝试了我的程序(一个有13个字符

和另外14个,并且该程序有效。 2个文件是否太大而且程序内存不足?
?我如何解决这个问题,因为我需要读取比这些更大的文件?


谢谢。


问候,

Rayne

Hi all,
I''m having programs reading from files.

I have a text file "files.txt" that contains the names of the files to
be opened, i.e. the contents of files.txt are

Homo_sapiens.fa
Rattus_norvegicus.fa

(They are FA files that can be opened in any text editor.)

Each of the FA files contains a number in the first line and a string
of characters (A,T,G or C). For example, the Homo_sapiens.fa file
would contain

16571
GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT TTGGTATTTT
CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGC ACCCTATGTC
GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTAC GTTCAATATT
ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGA CATAATAATA

and so on, with 16571 A,T,G or Cs.

Below is my code:

#include <stdio.h>
#include <stdlib.h>

#define MAX_FILE 100 // maximum length of file name
#define MAX_SEQ 20000 // maximum length of sequence
#define N 2 // total number of sequences

int main(void)
{
FILE *fin, *fin1, *fout;
char input[MAX_FILE+1], seq[N][MAX_SEQ+1], c;
int size[N], i = 0, j = 0;

fin = fopen("files.txt", "r");
fout = fopen("output.txt", "w");
while (fscanf(fin, "%s", input) != EOF)
{
fin1 = fopen(input, "r");
printf("%s\n", input);
fscanf(fin1, "%d ", &size[i]);
printf("%d\n", size[i]);
while ((c = fgetc(fin1)) != EOF)
{
fprintf(fout, "%c", c);
if (c != ''\n'')
seq[i][j] = c;
j++;
if (j % 100 == 0)
printf("%c", seq[i][j]);
}
fprintf(fout, "\n\n");
j = 0;
i++;
}

fclose(fin);
fclose(fin1);
fclose(fout);
return 0;
}

The printf statements for me to check my code.

When I try to open 2 files, the first file is read in fine, but the
second file is incomplete. Over 600 characters are not read, and the
program hangs.

I get the output (due to the checking printf statements)

Homo_sapiens.fa
16571
Rattus_norvegicus.fa
16300
<program hangs>

Notice that the statements
if (j % 100 == 0)
printf("%c", seq[i][j]);
are not executed, but if I just print the character seq[0][100], it
comes out correctly.

If I try to open 3 files, the same program happens, i.e. the first
file is read correctly, but the second file is incomplete and the
third file is not read at all. I get the output

Homo_sapiens.fa
16571
Rattus_norvegicus.fa
16300
Homo_sapiens.fa
16571
Segmentation fault

I tried my program with 2 much smaller files (one has 13 characters
and the other 14), and the program works. Are the 2 files too big and
the program ran out of memory? How do I get around this problem, as I
have to read files even bigger than these 2 later?

Thank you.

Regards,
Rayne

推荐答案



< la ******** @ yahoo.comwrote in message

news:11 ********************** @ l22g2000prc.googlegr oups.com ...

<la********@yahoo.comwrote in message
news:11**********************@l22g2000prc.googlegr oups.com...

大家好,

我正在从文件中读取程序。


我有一个文本文件files.txt其中包含要打开的文件的名称,即
的文件名,即files.txt的内容是


Homo_sapiens.fa

Rattus_norvegicus.fa


(它们是可以在任何文本编辑器中打开的FA文件。)


每个FA文件都包含一个数字在第一行和一个字符串

的字符(A,T,G或C)。例如,Homo_sapiens.fa文件

将包含


16571

GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT TTGGTATTTT

CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGC ACCCTATGTC

GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTAC GTTCAATATT

ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGA CATAATAATA

等等,16571 A,T,G或Cs。


以下是我的代码:


#include< stdio.h>

#include< stdlib.h>


#define MAX_FILE 100 //文件名最大长度

#define MAX_SEQ 20000 //最大序列长度

#定义N 2 //序列总数


int main(无效)

{

FILE * fin,* fin1, * fout;

char输入[MAX_FILE + 1],seq [N] [MAX_SEQ + 1],c;
Hi all,
I''m having programs reading from files.

I have a text file "files.txt" that contains the names of the files to
be opened, i.e. the contents of files.txt are

Homo_sapiens.fa
Rattus_norvegicus.fa

(They are FA files that can be opened in any text editor.)

Each of the FA files contains a number in the first line and a string
of characters (A,T,G or C). For example, the Homo_sapiens.fa file
would contain

16571
GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT TTGGTATTTT
CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGC ACCCTATGTC
GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTAC GTTCAATATT
ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGA CATAATAATA

and so on, with 16571 A,T,G or Cs.

Below is my code:

#include <stdio.h>
#include <stdlib.h>

#define MAX_FILE 100 // maximum length of file name
#define MAX_SEQ 20000 // maximum length of sequence
#define N 2 // total number of sequences

int main(void)
{
FILE *fin, *fin1, *fout;
char input[MAX_FILE+1], seq[N][MAX_SEQ+1], c;



Thjis line can导致问题,seq太大而不能安全地堆叠。

mak它是静态的。

Thjis line could cause problems, seq is too big to so safely on the stack.
make it static.


>

int size [N],i = 0,j = 0;


fin = fopen(" files.txt"," r");

fout = fopen(" output.txt"," w");
>
int size[N], i = 0, j = 0;

fin = fopen("files.txt", "r");
fout = fopen("output.txt", "w");



点击这里。

如果(!fin)/ *没有打开fin * /

if(| fout)/ *没有打开fout * /

Check here .
if(!fin) /* haven''t opened fin */
if(|fout) /* haven''t opened fout */


>

while(fscanf(fin,"%s",input)! = EOF)

{

fin1 = fopen(输入," r");
>
while (fscanf(fin, "%s", input) != EOF)
{
fin1 = fopen(input, "r");



点击此处

if(!fin1); / *不能打开fin 1 * /

Check here
if (!fin1); /* can''t open fin 1 */


>

printf("%s \ n",input) ;
>
printf("%s\n", input);



此诊断是否符合您的预期。我怀疑你不想要fscanf(),

你想要fgets()读取整行,然后砍掉尾随的换行符。

Is this diagnostic doing what you expect. I suspect you don''t want fscanf(),
you wnat fgets() to read a whole line, then chop of the trailing newline.


>

fscanf(fin1,"%d",& size [i]);

printf("%d \ n",size [i]);

while((c = fgetc(fin1))!= EOF)

{

fprintf(fout,"%c",c);

if(c!=''\ n'')

seq [i] [j] = c;

j ++;

if(j%100 == 0)

printf(" %c",seq [i] [j]);
>
fscanf(fin1, "%d ", &size[i]);
printf("%d\n", size[i]);
while ((c = fgetc(fin1)) != EOF)
{
fprintf(fout, "%c", c);
if (c != ''\n'')
seq[i][j] = c;
j++;
if (j % 100 == 0)
printf("%c", seq[i][j]);



如果(j> = MAX_SEQ -1)/ * j太大,超出空格,请检查此处* /

为方便起见,在结尾处加上空值,因此减去1.

Check here if(j >= MAX_SEQ -1) /* j too big, out of space */
Put a null on the end for convenience, hence the minus 1.


>

}

fprintf(fout," \ n\ n");

j = 0;

i ++;
>
}
fprintf(fout, "\n\n");
j = 0;
i++;



当我大于1时会发生什么?你会做一个非法的meory

访问。您需要检查(i> = N)/ *是否无法继续,超出空间* /

What happens when i goes greater than 1 ? You will do an illegal meory
access. You need to check if( i >= N) /* can''t continue, out of space */


>

}


fclose(fin);

fclose(fin1);

fclose(fout);

返回0;

}


printf语句让我查看我的代码。


什么时候我尝试打开2个文件,第一个文件被正确读取,但

第二个文件不完整。超过600个字符无法读取,

程序挂起。


我得到输出(由于检查printf语句)


Homo_sapiens.fa

16571

Rattus_norvegicus.fa

16300

< program hangs> ;


请注意语句

if(j%100 == 0)

printf("%c", seq [i] [j]);

没有被执行,但是如果我只是打印字符seq [0] [100],那么

就会正确显示。


如果我尝试打开3个文件,会发生相同的程序,即第一个

文件被正确读取,但第二个文件不完整且

根本没有读取第三个文件。我得到了输出


Homo_sapiens.fa

16571

Rattus_norvegicus.fa

16300

Homo_sapiens.fa

16571

分段错误


我用2个小得多的文件尝试了我的程序(一个有13个字符

和另外14个,并且该程序有效。 2个文件是否太大而且程序内存不足?
?我如何解决这个问题,因为我需要读取比这些更大的文件?


谢谢。


问候,

Rayne
>
}

fclose(fin);
fclose(fin1);
fclose(fout);
return 0;
}

The printf statements for me to check my code.

When I try to open 2 files, the first file is read in fine, but the
second file is incomplete. Over 600 characters are not read, and the
program hangs.

I get the output (due to the checking printf statements)

Homo_sapiens.fa
16571
Rattus_norvegicus.fa
16300
<program hangs>

Notice that the statements
if (j % 100 == 0)
printf("%c", seq[i][j]);
are not executed, but if I just print the character seq[0][100], it
comes out correctly.

If I try to open 3 files, the same program happens, i.e. the first
file is read correctly, but the second file is incomplete and the
third file is not read at all. I get the output

Homo_sapiens.fa
16571
Rattus_norvegicus.fa
16300
Homo_sapiens.fa
16571
Segmentation fault

I tried my program with 2 much smaller files (one has 13 characters
and the other 14), and the program works. Are the 2 files too big and
the program ran out of memory? How do I get around this problem, as I
have to read files even bigger than these 2 later?

Thank you.

Regards,
Rayne


2007年8月25日星期六02:35:35 -0700, la********@yahoo.com 写道:
On Sat, 25 Aug 2007 02:35:35 -0700, la********@yahoo.com wrote:

大家好,

我正在从文件中读取程序。


我有一个文本文件files.txt ;其中包含要打开的文件的名称,即
的文件名,即files.txt的内容是


Homo_sapiens.fa

Rattus_norvegicus.fa


(它们是可以在任何文本编辑器中打开的FA文件。)

每个FA文件在第一行包含一个数字和一个字符串

的字符(A,T,G或C)。例如,Homo_sapiens.fa文件

将包含


16571

GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT TTGGTATTTT

CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGC ACCCTATGTC

GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTAC GTTCAATATT

ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGA CATAATAATA

等等,16571 A,T,G或Cs。


以下是我的代码:


#include< stdio.h>

#include< stdlib.h>


#define MAX_FILE 100 //文件名的最大长度
Hi all,
I''m having programs reading from files.

I have a text file "files.txt" that contains the names of the files to
be opened, i.e. the contents of files.txt are

Homo_sapiens.fa
Rattus_norvegicus.fa

(They are FA files that can be opened in any text editor.)
Each of the FA files contains a number in the first line and a string
of characters (A,T,G or C). For example, the Homo_sapiens.fa file
would contain

16571
GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT TTGGTATTTT
CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGC ACCCTATGTC
GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTAC GTTCAATATT
ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGA CATAATAATA

and so on, with 16571 A,T,G or Cs.

Below is my code:

#include <stdio.h>
#include <stdlib.h>

#define MAX_FILE 100 // maximum length of file name



stdio.h包含一个用于此目的的宏FILENAME_MAX。

它已包含终止空值的空间。

stdio.h contains a macro FILENAME_MAX for that purpose.
It already includes room for the terminating null.


#define MAX_SEQ 20000 //最大序列长度

#define N 2 //序列总数


int main(无效)

{

FILE * fin,* fin1,* fout;

char输入[MAX_FILE +1],seq [N] [MAX_SEQ + 1],c;
#define MAX_SEQ 20000 // maximum length of sequence
#define N 2 // total number of sequences

int main(void)
{
FILE *fin, *fin1, *fout;
char input[MAX_FILE+1], seq[N][MAX_SEQ+1], c;



尝试将它们设为静态,40 KB的自动变量可能太多了。

Try making them static, 40 KB of auto variables could be too much.


int size [N],i = 0,j = 0;


fin = fopen(" files。 txt"," r");

fout = fopen(" output.txt"," w");
int size[N], i = 0, j = 0;

fin = fopen("files.txt", "r");
fout = fopen("output.txt", "w");



你应该检查一下是否有效,否则就应对。

You should check whether those work, and cope with that otherwise.


while(fscanf(fin,"%s",input)!= EOF)
while (fscanf(fin, "%s", input) != EOF)



%s将停止在任何空格字符上,而不仅仅是换行符。

那好吗? (顺便说一句,如果files.txt包含一个名字为

太长会怎么样?)

%s will stop on any whitespace character, not just newlines. Is
that ok? (BTW, what happens if files.txt contains a name which is
too long?)


{

fin1 = fopen(输入,r);

printf("%s \ n",输入);

fscanf(fin1,"% d",& size [i]);

printf("%d \ n",size [i]);

while((c = fgetc(fin1))!= EOF)
{
fin1 = fopen(input, "r");
printf("%s\n", input);
fscanf(fin1, "%d ", &size[i]);
printf("%d\n", size[i]);
while ((c = fgetc(fin1)) != EOF)



c被声明为char。如果它是未签名的,它永远不会等于
EOF。如果签名,一些有效的角色(虽然没有ACGT)

可能被误认为是EOF。 fgetc返回一个int。请参阅 www.c-faq.com

部分12,问题1.

c is declared as a char. If it is unsigned it will never equal
EOF. If it is signed, some valid character (though none of ''ACGT'')
could be mistaken as EOF. fgetc returns an int. See www.c-faq.com,
section 12, question 1.


{

fprintf(fout,"%c",c);

if(c!=''\ n'')

seq [i] [j] = c;

j ++;
{
fprintf(fout, "%c", c);
if (c != ''\n'')
seq[i][j] = c;
j++;



注意,即使c是''\ n'',j也会递增,在

这种情况​​下会有差距顺序。添加大括号需要


Note that j will be incremented even if c is ''\n'', in
this case there will be a gap in the sequence. Add braces where
needed.


if(j%100 == 0)

printf("%c",seq [i] [j]);
if (j % 100 == 0)
printf("%c", seq[i][j]);



你已经增加了j,所以seq [i] [j]将被取消初始化

。例如,如果在循环体的开头

j是99而c是''T''你会把c写入seq [i] [99],

将j增加到100,并打印seq [i] [100]。

You''re already incremented j, so seq[i][j] will be uninitialized
at this time. For example, if at the beginning of the loop body
j were 99 and c were ''T'' you would write c into seq[i][99],
increment j to 100, and print seq[i][100].


}

fprintf(fout," \ n\ n");

j = 0 ;

i ++;

}


fclose(fin);

fclose(fin1);

fclose(fout);
}
fprintf(fout, "\n\n");
j = 0;
i++;
}

fclose(fin);
fclose(fin1);
fclose(fout);



理想情况下,你应该检查fclose()是否在没有

问题的情况下工作。

Ideally you should check whether the fclose() worked without
problems.


返回0;

}
return 0;
}



-

Army1987(将NOSPAM替换为电子邮件)

没有人通过辞职赢得比赛。 - S. Tartakower

--
Army1987 (Replace "NOSPAM" with "email")
No-one ever won a game by resigning. -- S. Tartakower


" la ******** @ yahoo.com"写道:
"la********@yahoo.com" wrote:

>

我正在从文件中读取程序。


我有一个文本文件files.txt其中包含要打开的文件的名称,即
的文件名,即files.txt的内容是


Homo_sapiens.fa

Rattus_norvegicus.fa


(它们是可以在任何文本编辑器中打开的FA文件。)


每个FA文件都包含一个数字在第一行和一个字符串

的字符(A,T,G或C)。例如,Homo_sapiens.fa文件

将包含


16571

GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT TTGGTATTTT

CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGC ACCCTATGTC

GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTAC GTTCAATATT

ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGA CATAATAATA

等等,16571 A,T,G或Cs。


以下是我的代码:


#include< stdio.h>

#include< stdlib.h>


#define MAX_FILE 100 //文件名最大长度

#define MAX_SEQ 20000 //最大序列长度

#定义N 2 //序列总数


int main(无效)

{

FILE * fin,* fin1, * fout;

char输入[MAX_FILE + 1],seq [N] [MAX_SEQ + 1],c;

int size [N],i = 0,j = 0;


fin = fopen(" files.txt"," r&qu ot;);

fout = fopen(" output.txt"," w");
>
I''m having programs reading from files.

I have a text file "files.txt" that contains the names of the files to
be opened, i.e. the contents of files.txt are

Homo_sapiens.fa
Rattus_norvegicus.fa

(They are FA files that can be opened in any text editor.)

Each of the FA files contains a number in the first line and a string
of characters (A,T,G or C). For example, the Homo_sapiens.fa file
would contain

16571
GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT TTGGTATTTT
CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGC ACCCTATGTC
GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTAC GTTCAATATT
ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGA CATAATAATA

and so on, with 16571 A,T,G or Cs.

Below is my code:

#include <stdio.h>
#include <stdlib.h>

#define MAX_FILE 100 // maximum length of file name
#define MAX_SEQ 20000 // maximum length of sequence
#define N 2 // total number of sequences

int main(void)
{
FILE *fin, *fin1, *fout;
char input[MAX_FILE+1], seq[N][MAX_SEQ+1], c;
int size[N], i = 0, j = 0;

fin = fopen("files.txt", "r");
fout = fopen("output.txt", "w");



您未能检查fopen调用是否成功。

You fail to check for success of the fopen calls.


while(fscanf(fin,") ;%s",input)!= EOF){

fin1 = fopen(输入," r");

printf("%s \ n" ,输入);

fscanf(fin1,"%d",& size [i]);
while (fscanf(fin, "%s", input) != EOF) {
fin1 = fopen(input, "r");
printf("%s\n", input);
fscanf(fin1, "%d ", &size[i]);



您未能检查fscanf调用是否成功。

You fail to check for success of the fscanf call.


printf("%d \\ \\ n",size [i]);

while((c = fgetc(fin1))!= EOF){
printf("%d\n", size[i]);
while ((c = fgetc(fin1)) != EOF) {



c can永远不会是EOF,因为你错误地宣称它是一个

char。它应该是一个int。

c can never be EOF, because you have erroneously declared it a
char. It should be an int.


fprintf(fout,"%c",c);

if(c!='' \ n'')

seq [i] [j] = c;

j ++;

if(j%100 == 0 )

printf("%c",seq [i] [j]);

}

fprintf(fout," \\ \\ n \ n");

j = 0;

i ++;
fprintf(fout, "%c", c);
if (c != ''\n'')
seq[i][j] = c;
j++;
if (j % 100 == 0)
printf("%c", seq[i][j]);
}
fprintf(fout, "\n\n");
j = 0;
i++;



在尝试将fin1附加到另一个

文件之前,你无法关闭它。

You fail to close fin1 before attempting to attach it to another
file.


}


fclose(fin);

fclose(fin1);

fclose(fout);

返回0;

}


printf语句供我检查我的代码。


当我尝试打开2个文件时,第一个文件被正确读取,但

秒文件不完整。超过600个字符未被读取,并且

程序挂起。
}

fclose(fin);
fclose(fin1);
fclose(fout);
return 0;
}

The printf statements for me to check my code.

When I try to open 2 files, the first file is read in fine, but the
second file is incomplete. Over 600 characters are not read, and the
program hangs.



损失金额(在导致未定义的行为之后)导致我

怀疑您的系统INT_MAX设置为32767.如果是这样,你将需要长时间使用以确保32位能力。


-

Chuck F(cinefalconer at maineline dot net )

可用于咨询/临时嵌入式和系统。

< http://cbfalconer.home.att.net>

-

通过 http://www.teranews.com上的免费Usenet帐户发布

The amount of loss (after causing undefined behaviour) leads me to
suspect that your system has INT_MAX set at 32767. If so, you will
need to use long to ensure 32 bit ability.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com


这篇关于从文件中读取问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆