如何计算文件中整数/双精度的行和列? [英] how to count rows and columns of integers/doubles in a file?

查看:88
本文介绍了如何计算文件中整数/双精度的行和列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一些文件包含以下内容:


0 0 0 0 0 0

0 1 1 1 1 0

0 1 1 1 1 0

0 1 1 1 1 0

0 1 1 1 1 0

0 0 0 0 0 0


我正在为一个更大的程序做一个功能,那个


1)计算每行中的列数

2)验证每行中的列数是否相同

(如果不是:错误+退出)

3)在一行完成后递增行计数

4)如果遇到任何不是

整数的事情,则停止执行(稍后:应该也适用于双打)


我唯一的问题是我不知道如何切换线(支架

返回)或如何使用它来检测它scanf函数。除此之外,

计划差不多完成了。见下文:

- - - - - - - - - - - - - - - -

#include< stdio.h>

void int_getdata(char * filename,unsigned int * x,unsigned int

* y);

int main()

{

unsigned int n_x [3],n_y [3];


int_getdata(" unknowns.dat",& n_x [0],& n_y [ 0]);

int_getdata(" BC_types.dat",& n_x [1],& n_y [1]);

// double_getdata(" BC_values.dat",& n_x [2],& n_y [2]);


返回0;

}


void int_getdata(char * filename,unsigned int * x,unsigned int

* y)

{

FILE * fp;


unsigned int old_nx;

int int_readvalue,returnvalue;

// double double_readvalue;


old_nx = 0; / *重置* /

* x = 0;

* y = 0;


if((fp = fopen( filename,r,)== NULL)

{

printf(无法打开文件%s。\ n,文件名);

system(PAUSE); / *让用户有机会在Windows关闭之前看到这个

错误* /

退出(1);

}


/ *得到nx和ny * /

做{

returnvalue = fscanf(fp,"%i",& int_readvalue); / *所有

输入必须有效* /


if(returnvalue == 1)(* x)++; / * nx越来越大* /

else {

printf(错误:在%s。\ n中找到无效输入,

filename);

退出(1);

}


if(int_readvalue ==''\ n'')

{

if(old_nx!= 0&& old_nx!= * x)

{

printf(" ERROR:nx不是文件中的常量

%s!\ n",filename);

exit(1);

}

else / *我们现在应该确定nx是常数并且

继续下一个输入行* /

{

old_nx = * x;

y ++; / * ny越来越大* /

* x = 0;

}

}

}而( returnvalue!= EOF);


printf(\ nFinished从文件%s读取:(x,y)=(%i,%i)。\ n,

filename,* x,* y);

fclose(fp); / *关闭输入文件,读完后的价值

* /

}


- - - - - - - - - - - - - - - -


我希望有人可以帮我解决这个小问题,所以我可以用b $ b来完成这个程序....... />

我也收到这些小警告,但它们并不重要:


警告C4013:''system''未定义;假设extern返回int


警告C4013:''退出''undefined;假设extern返回int

最好的问候/ Med venlig hilsen

Martin J?rgensen


-

------------------------------------------------ ---------------------------

Martin J?rgensen的故乡 - http://www.martinjoergensen.dk

Hi,

I have some files which has the following content:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

I''m making a function for a bigger program, that

1) counts number of columns in each row
2) verifies that there are the same number of columns in each row
(if not: error + quit)
3) increments row count after one row is finished
4) stops execution if it encounters anything that is not an
integer (later: should also work for doubles)

My only problem is that I don''t know how to switch line (carriage
return) or how to detect it using scanf. Besides that, the
program is almost finished. See below:
- - - - - - - - - - - - - - - -
#include <stdio.h>
void int_getdata(char *filename, unsigned int *x, unsigned int
*y);
int main()
{
unsigned int n_x[3], n_y[3];

int_getdata("unknowns.dat", &n_x[0], &n_y[0] );
int_getdata("BC_types.dat", &n_x[1], &n_y[1] );
// double_getdata("BC_values.dat", &n_x[2], &n_y[2] );

return 0;
}

void int_getdata(char *filename, unsigned int *x, unsigned int
*y)
{
FILE *fp;

unsigned int old_nx;
int int_readvalue, returnvalue;
//double double_readvalue;

old_nx = 0; /* reset */
*x = 0;
*y = 0;

if ( (fp = fopen(filename, "r") ) == NULL)
{
printf("Cannot open file %s.\n", filename);
system("PAUSE"); /* give the user at chance to see this
error before the windows shuts down */
exit(1);
}

/* get nx and ny */
do{
returnvalue = fscanf(fp, "%i", &int_readvalue); /* all
input must be valid */

if(returnvalue == 1) (*x)++; /* nx is getting larger */
else{
printf("Error: non-valid input found in %s.\n",
filename);
exit(1);
}

if(int_readvalue == ''\n'')
{
if(old_nx != 0 && old_nx != *x)
{
printf("ERROR: nx is not a constant in file
%s!\n", filename);
exit(1);
}
else /* we should now be sure that nx is constant and
move on to the next input line */
{
old_nx = *x;
y++; /* ny is getting larger */
*x = 0;
}
}
} while(returnvalue != EOF);

printf("\nFinished reading from file %s: (x,y) = (%i,%i).\n",
filename, *x, *y);
fclose(fp); /* close input file, finished reading values in
*/
}

- - - - - - - - - - - - - - - -

I hope somebody can help me solve this small problem, so I can
finish the program....

I also get these small warnings, but they are not critical:

warning C4013: ''system'' undefined; assuming extern returning int

warning C4013: ''exit'' undefined; assuming extern returning int
Best regards / Med venlig hilsen
Martin J?rgensen

--
---------------------------------------------------------------------------
Home of Martin J?rgensen - http://www.martinjoergensen.dk

推荐答案

Martin Joergensen schrieb:
Martin Joergensen schrieb:
我有一些文件包含以下内容:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

我正在为更大的程序创建一个函数,

1)计算每行中的列数
2)验证每行中的列数是否相同(如果
不:错误+退出)
3)一行完成后递增行数
4)如果遇到任何不是整数的事情就停止执行
(l) ater:也应该为双打工作)

我唯一的问题是我不知道如何切换线(支架返回)或如何使用scanf检测它。


一行的结尾用C中的''\ n''表示。

如果你用C程序写文件的话,和

阅读和写作程序在同一个地方,

然后你就不需要照顾任何东西,只要你

使用文本流。只有当你明确打开一个二进制的

流时,你必须看一下''\ n''的实际表示



所以,如果你专注于1)到3),你可以读取像这样的行数和列数

。如果你不想检查自己,你需要某种字符串

缓冲区。


int countRowsAndCols(FILE * pFile,unsigned * pRows, unsigned * pCols)

{

unsigned rows,cols,oldcols;

int isConsistent = 1;


/ *这里定义文件* /


rows = 0;

if(countColsInNextLine(pFile,& oldcols)!= EOF){

行++;

while(countColsInNextLine(pFile,& cols)!= EOF){

rows ++;

if(cols!= oldcols){

isConsistent = 0;

/ *您的错误信息在这里* /

}

}

}


* pRows =行;

* pCols = oldcols;

return!isConsistent;

}




int countColsInNextLine(FILE * pFile,unsigned * pCols)

{

int c;

unsigned cols = 0;


do {

c = getc(pFile);

if(c!= EOF&&!isspace(c )){

cols ++;

do {

c = getc(pFile);

} while(c! = EOF&& !isspace(c));

}

while(c!= EOF&& c!=''\ n''&& isspace( c)){

c = getc(pFile);

}

} while(c!= EOF&& c!=' '\ n'')


* pCols = cols;

返回c;

}

你消耗文件中的字符,直到你找到

换行符或文件结尾。

你从getc()返回最后一个结果,即EOF如果

文件结束。这些功能没有经过测试。

你可以通过引入适当的辅助功能来使第二个功能更轻松。

上面没有经过测试。

除此之外,该程序几乎完成了。见下文:
- - - - - - - - - - - - - - - -
#include< stdio.h>

void int_getdata(char * filename, unsigned int * x,unsigned int * y);

int main()
{
unsigned int n_x [3],n_y [3];

int_getdata(" unknowns.dat",& n_x [0],& n_y [0]);
int_getdata(" BC_types.dat",& n_x [1],& n_y [ 1]);
// double_getdata(" BC_values.dat",& n_x [2],& n_y [2]);

返回0;
}

void int_getdata(char * filename,unsigned int * x,unsigned int * y)
{
FILE * fp;

unsigned int old_nx;
int int_readvalue,returnvalue;
// double double_readvalue;

old_nx = 0; / * reset * /
* x = 0;
* y = 0;

if((fp = fopen(filename," r"))== NULL)
{
printf(无法打开文件%s。\ n,文件名);
系统(暂停); / *让用户有机会在Windows关闭之前看到此错误
退出(1);
}

/ *获取nx和ny * /
做{
returnvalue = fscanf(fp,"%i",& int_readvalue); / *所有输入必须
有效* /

if(returnvalue == 1)(* x)++; / * nx越来越大* /
否则{
printf(错误:在%s。\ n"中找到无效输入,文件名);
exit(1);
}

if(int_readvalue ==''\ n'')


这不是你想要的。你将read

整数的值与int常量''\ n''的值进行比较。

{
if(old_nx!= 0 && old_nx!= * x)
{/> printf(错误:nx不是文件%s中的常量!\ n,
文件名);
退出(1);
}
其他/ *我们现在应该确保nx是常量并继续前进到下一个输入行* /
{
old_nx = * x;
y ++; / * ny越来越大* /
* x = 0;
}
}
} while(returnvalue!= EOF);

printf( \ nFinished从文件%s读取:(x,y)=(%i,%i)。\ n",
filename,* x,* y);
fclose(fp ); / *关闭输入文件,读完* /
中的值

- - - - - - - - - - - - - - - -

我希望有人能帮我解决这个小问题,所以我可以完成程序....


即使你可以在

扫描集(%[]或%[^]),它可能更容易在

a行读取并使用sscanf()甚至strtoul()检查值。 >
或strtod()。如果您只需要原先指定的

空间 - 非空间区别,请查看建议的

功能。

我们已经领先如何阅读一条线讨论,所以你

可以查看相应的帖子。


我也收到这些小警告,但它们并不重要:
<警告C4013:''system''未定义;假设extern返回int

警告C4013:''退出''undefined;假设extern返回int
I have some files which has the following content:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

I''m making a function for a bigger program, that

1) counts number of columns in each row
2) verifies that there are the same number of columns in each row (if
not: error + quit)
3) increments row count after one row is finished
4) stops execution if it encounters anything that is not an integer
(later: should also work for doubles)

My only problem is that I don''t know how to switch line (carriage
return) or how to detect it using scanf.
The end of a line is indicated by ''\n'' in C.
If you are writing the file with a C programme, too, and
the reading and the writing programme are in the same locale,
then you do not have to take care of anything as long as you
work with text streams. Only if you explicitly open a binary
stream, then you have to look at the actual representation
of ''\n''.
So, you can read in the number of lines and columns like this
if you concentrate on 1) to 3). You need some sort of string
buffer for 4) if you do not want to check yourself.

int countRowsAndCols (FILE *pFile, unsigned *pRows, unsigned *pCols)
{
unsigned rows, cols, oldcols;
int isConsistent = 1;

/* define file here */

rows = 0;
if (countColsInNextLine(pFile, &oldcols) != EOF) {
rows++;
while (countColsInNextLine(pFile, &cols) != EOF) {
rows++;
if (cols != oldcols) {
isConsistent = 0;
/* Your error message here */
}
}
}

*pRows = rows;
*pCols = oldcols;
return !isConsistent;
}

In
int countColsInNextLine (FILE *pFile, unsigned *pCols)
{
int c;
unsigned cols = 0;

do {
c = getc(pFile);
if (c != EOF && !isspace(c)) {
cols++;
do {
c = getc(pFile);
} while (c != EOF && !isspace(c));
}
while (c != EOF && c != ''\n'' && isspace(c)) {
c = getc(pFile);
}
} while (c != EOF && c != ''\n'')

*pCols = cols;
return c;
}
you consume characters from the file until you find
either a line break or the end of the file.
You return the last result from getc(), i.e. EOF if the
file ends. The functions are not tested.
You could make life easier in the second function by
introducing appropriate auxiliary functions.
The above is not tested.
Besides that, the program is
almost finished. See below:
- - - - - - - - - - - - - - - -
#include <stdio.h>
void int_getdata(char *filename, unsigned int *x, unsigned int *y);
int main()
{
unsigned int n_x[3], n_y[3];

int_getdata("unknowns.dat", &n_x[0], &n_y[0] );
int_getdata("BC_types.dat", &n_x[1], &n_y[1] );
// double_getdata("BC_values.dat", &n_x[2], &n_y[2] );

return 0;
}

void int_getdata(char *filename, unsigned int *x, unsigned int *y)
{
FILE *fp;

unsigned int old_nx;
int int_readvalue, returnvalue;
//double double_readvalue;

old_nx = 0; /* reset */
*x = 0;
*y = 0;

if ( (fp = fopen(filename, "r") ) == NULL)
{
printf("Cannot open file %s.\n", filename);
system("PAUSE"); /* give the user at chance to see this error
before the windows shuts down */
exit(1);
}

/* get nx and ny */
do{
returnvalue = fscanf(fp, "%i", &int_readvalue); /* all input must
be valid */

if(returnvalue == 1) (*x)++; /* nx is getting larger */
else{
printf("Error: non-valid input found in %s.\n", filename);
exit(1);
}

if(int_readvalue == ''\n'')
This is not what you want. You compare the value of the read
integer against the value of the int constant ''\n''.
{
if(old_nx != 0 && old_nx != *x)
{
printf("ERROR: nx is not a constant in file %s!\n",
filename);
exit(1);
}
else /* we should now be sure that nx is constant and move on
to the next input line */
{
old_nx = *x;
y++; /* ny is getting larger */
*x = 0;
}
}
} while(returnvalue != EOF);

printf("\nFinished reading from file %s: (x,y) = (%i,%i).\n",
filename, *x, *y);
fclose(fp); /* close input file, finished reading values in */
}

- - - - - - - - - - - - - - - -

I hope somebody can help me solve this small problem, so I can finish
the program....
Even though you can do certain things with the help of
scan sets (%[] or %[^]), it is probably easier to read in
a line and check the values with sscanf() or even strtoul()
or strtod(). If you only need the originally indicated
space -- non-space distinction, have a look at the suggested
functions.
We already lead the "how to read a line" discussion, so you
can just look up the respective thread.

I also get these small warnings, but they are not critical:

warning C4013: ''system'' undefined; assuming extern returning int

warning C4013: ''exit'' undefined; assuming extern returning int




他们是。你忘了#include< stddef.h>,所以你没有得到

函数的正确类型。

特别是,参数不会自动转换而且

如果无法转换,你不会收到警告。对于这些两个函数,一切都可能按预期工作但

警告背后有严重错误。

干杯

Michael

-

电子邮箱:我的是/ at / gmx / dot / de地址。



They are. You forgot to #include <stddef.h>, so you did not get
proper types for the functions.
Especially, the arguments are not converted automatically and
you don''t get a warning if they cannot be converted. For these
two functions, everything probably will work as intended but
there is a serious error behind the warning.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.


" Martin Joergensen" <未********* @ spam.jay.net>写道:
"Martin Joergensen" <un*********@spam.jay.net> writes:
我有一些文件包含以下内容:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

我正在为...一个更大的程序,

1)计算每行中的列数


你是什么意思列? 0 0 0 0 0 0是否为0 0 0 0 0 0。有6列

(数字)或11(字符)?


[snip]

returnvalue = fscanf(fp," ;%i",& int_readvalue); / *所有输入
必须有效* /
I have some files which has the following content:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

I''m making a function for a bigger program, that

1) counts number of columns in each row
What do you mean by "columns"? Does "0 0 0 0 0 0" have 6 columns
(numbers) or 11 (characters)?

[snip]
returnvalue = fscanf(fp, "%i", &int_readvalue); /* all input
must be valid */




前导空格(包括换行符)后,format会读取一个整数值。它没有表明它跳过了什么。如果新行是重要的,那就是错误的

方法。


它还接受十进制,八进制或十六进制输入。决定

是否要允许0xff等数字,以及是否需要

" 0123"以八进制(产生83)或十进制来解释

(产生123)。既然你提到你最终会想要使用

程序来处理双打,你可能不想接受八进制

或十六进制;你可能想要%d而不是%i。 (%d和

%i对* printf函数的行为相同,但对于

* scanf函数则不同。


一个更好的方法是使用fgets()一次读取一行,然后使用sscanf()扫描生成的行。 sscanf(),不像

fscanf(),不消耗它的输入;它仍然在字符串中,

如果sscanf()调用失败(检查其返回值),你可以再次尝试



fgets()的缺点是它只能读取指定长度的行。

。如果输入行长于指定的
,则fgets()将只读取其中的一部分;您可以通过

检测到这一点,您刚刚阅读的行是否以''\ n''结尾。如果你只想让b $ b允许输入行达到某个最大长度,这不是一个很大的问题 - 但是你仍然应该决定该怎么办输入行

超过最大值。如果你想处理任意长的输入

行,你可以使用CBFalconer'''ggets" (谷歌)。


-

Keith Thompson(The_Other_Keith) ks ***@mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。



fscanf with a "%i" format reads an integer value after skipping any
leading whitespace -- including new-lines. It gives no indication of
what it skipped. If new-lines are significant, that''s the wrong
approach.

It also accepts either decimal, octal, or hexadecimal input. Decide
whether you want to allow numbers like "0xff", and whether you want
"0123" to be interpreted in octal (yielding 83) or in decimal
(yielding 123). Since you mentioned you''ll eventually want the
program to work with doubles, you probably don''t want to accept octal
or hexadecimal; you probably want "%d" rather than "%i". ("%d" and
"%i" behave identically for the *printf functions, but differently for
the *scanf functions).

A much better approach is to use fgets() to read a line at a time,
then use sscanf() to scan the resulting line. sscanf(), unlike
fscanf(), doesn''t consume its input; it''s still there in the string,
and if the sscanf() call fails (check its returned value), you can try
again.

fgets() has the disadvantage that it can only read a line up to a
specified length. If the input line is longer than what you
specified, fgets() will read only part of it; you can detect this by
whether the line you just read ends in a ''\n''. If you only want to
allow input lines up to some maximum length, this isn''t much of a
problem -- but you should still decide what to do if an input line
exceeds your maximum. If you want to handle arbitrarily long input
lines, you can use CBFalconer''s "ggets" (Google it).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


2006年3月15日星期三20:32:04 +0100,Martin Joergensen

< ;未********* @ spam.jay.net>写道:
On Wed, 15 Mar 2006 20:32:04 +0100, "Martin Joergensen"
<un*********@spam.jay.net> wrote:


我有一些文件包含以下内容:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

我正在为一个更大的程序创建一个函数,

1)计算每一行中的列数
2)验证是否有相同数量的列每行中的列
(如果不是:错误+退出)
3)在一行完成后递增行计数
4)如果遇到任何不是
的任何内容,则停止执行整数(后来:也适用于双打)

我唯一的问题是我不知道如何切换线(回车)或如何使用scanf检测它。除此之外,
程序几乎完成了。见下文:
- - - - - - - - - - - - - - - -
#include< stdio.h>

void int_getdata(char * filename, unsigned int * x,unsigned int
* y);

int main()
{
unsigned int n_x [3],n_y [3];

int_getdata(" unknowns.dat",& n_x [0],& n_y [0]);
int_getdata(" BC_types.dat",& n_x [1], & n_y [1]);
// double_getdata(" BC_values.dat",& n_x [2],& n_y [2]);

返回0;
}

void int_getdata(char * filename,unsigned int * x,unsigned int
* y)
{
FILE * fp;

unsigned int old_nx;
int int_readvalue,returnvalue;
// double double_readvalue;

old_nx = 0; / * reset * /
* x = 0;
* y = 0;

if((fp = fopen(filename," r"))== NULL)
{
printf(无法打开文件%s。\ n,文件名);
系统(暂停); / *让用户有机会在Windows关闭之前看到这个
错误* /
退出(1);
}

/ *获取nx和ny * /
做{
returnvalue = fscanf(fp,"%i",& int_readvalue); / *所有
输入必须是有效的* /


fscanf将吃掉空格,包括标记结束的\ n
行。


您可以使用fgets获得完整的行,然后strtol处理每个

值的正确性。

if(returnvalue) == 1)(* x)++; / * nx越来越大* /
否则{
printf(错误:%s。\ n中找到无效输入,
文件名);
退出(1);
}
if(int_readvalue ==''\ n'')
{
if(old_nx!= 0&& old_nx != * x)
{/> printf(错误:nx不是文件中的常量
%s!\ n,文件名);
exit(1) ;
}
其他/ *我们现在应该确保nx是常数并且
继续前进到下一个输入行* /
{
old_nx = * x;
y ++; / * ny越来越大* /
* x = 0;
}
}
} while(returnvalue!= EOF);

printf( \ nFinished从文件%s读取:(x,y)=(%i,%i)。\ n",
filename,* x,* y);
fclose(fp ); / *关闭输入文件,完成阅读值
* /
}
- - - - - - - - - - - - - - - -
<我希望有人可以帮我解决这个小问题,所以我可以完成这个程序....

我也收到这些小警告,但它们并不重要:<警告C4013:''system''未定义;假设extern返回int

警告C4013:''退出''undefined;假设extern返回int

最好的问候/ Med venlig hilsen
Martin J?rgensen
Hi,

I have some files which has the following content:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

I''m making a function for a bigger program, that

1) counts number of columns in each row
2) verifies that there are the same number of columns in each row
(if not: error + quit)
3) increments row count after one row is finished
4) stops execution if it encounters anything that is not an
integer (later: should also work for doubles)

My only problem is that I don''t know how to switch line (carriage
return) or how to detect it using scanf. Besides that, the
program is almost finished. See below:
- - - - - - - - - - - - - - - -
#include <stdio.h>
void int_getdata(char *filename, unsigned int *x, unsigned int
*y);
int main()
{
unsigned int n_x[3], n_y[3];

int_getdata("unknowns.dat", &n_x[0], &n_y[0] );
int_getdata("BC_types.dat", &n_x[1], &n_y[1] );
// double_getdata("BC_values.dat", &n_x[2], &n_y[2] );

return 0;
}

void int_getdata(char *filename, unsigned int *x, unsigned int
*y)
{
FILE *fp;

unsigned int old_nx;
int int_readvalue, returnvalue;
//double double_readvalue;

old_nx = 0; /* reset */
*x = 0;
*y = 0;

if ( (fp = fopen(filename, "r") ) == NULL)
{
printf("Cannot open file %s.\n", filename);
system("PAUSE"); /* give the user at chance to see this
error before the windows shuts down */
exit(1);
}

/* get nx and ny */
do{
returnvalue = fscanf(fp, "%i", &int_readvalue); /* all
input must be valid */
fscanf will eat white space, including the \n that marks the end of
line.

You could use fgets to get a complete line then strtol to process each
value for correctness.

if(returnvalue == 1) (*x)++; /* nx is getting larger */
else{
printf("Error: non-valid input found in %s.\n",
filename);
exit(1);
}

if(int_readvalue == ''\n'')
{
if(old_nx != 0 && old_nx != *x)
{
printf("ERROR: nx is not a constant in file
%s!\n", filename);
exit(1);
}
else /* we should now be sure that nx is constant and
move on to the next input line */
{
old_nx = *x;
y++; /* ny is getting larger */
*x = 0;
}
}
} while(returnvalue != EOF);

printf("\nFinished reading from file %s: (x,y) = (%i,%i).\n",
filename, *x, *y);
fclose(fp); /* close input file, finished reading values in
*/
}

- - - - - - - - - - - - - - - -

I hope somebody can help me solve this small problem, so I can
finish the program....

I also get these small warnings, but they are not critical:

warning C4013: ''system'' undefined; assuming extern returning int

warning C4013: ''exit'' undefined; assuming extern returning int
Best regards / Med venlig hilsen
Martin J?rgensen



删除del电子邮件


Remove del for email


这篇关于如何计算文件中整数/双精度的行和列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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