读写列 [英] read and write columns

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

问题描述

如果没有一些帮助或提示,我认为我无法做到这一点。这是代码

我有。


#include< stdio.h>

#include< stdlib.h> ;


双输入(双输入){

int count = 0,div = 0;

double mean = 0, linput = 0;

FILE * fpr,* fpw;

mean = input + linput / count;

if((fpw = fopen( 数据,w))!= EOF);

if((fpr = fopen(" data"," r"))!= EOF);

if((fscanf(fpr,input,linput,mean))== 0;

fprintf(fpw,"%d \ t%d \ t%d \\ n \\ n,输入,输入+输入,意思是);

}


这是非常不完整的。我有两个流打开一个用于阅读还有一个

的写作,但是我一直在谈论的计数,我不知道如何增加它的价值。


比尔

解决方案

比尔坎宁安说:


我不是我想如果没有一些帮助我可以做到这一点o提示。这是

代码

我有。


#include< stdio.h>

#include< stdlib.h>


双输入(双输入){

int count = 0,div = 0;



div是< stdlib.h>中原型的标准C库函数,因此这个

定义div" shadows"该功能,阻止您使用它。

最好避免使用标准C库函数名称,除非

引用标准C库函数。
< blockquote class =post_quotes>
double mean = 0,linput = 0;

FILE * fpr,* fpw;

mean = input + linput / count ;

if((fpw = fopen(" data"," w"))!= EOF);



你有K& R2。在失败时查找fopen的返回值。你之前已经被告知

了,最近也是这样。


-

Richard Heathfield< http ://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日


2008年7月3日星期四00:12:03 GMT,Bill Cunningham < no **** @ nspam.com>

写道:


我不认为没有一些我能做到这一点帮助或提示。这是我的代码。

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

双输入(双输入){

int count = 0,div = 0;



空白区域是免费的。使用它使你的代码可读。


double mean = 0,linput = 0;

FILE * fpr,* fpw;

mean = input + linput / count;



count的值是多少?您是否允许除以该值?


if((fpw = fopen(" data,w))!= EOF);



你的编译器没有生成诊断吗?什么类型和范围

的EOF? fopen返回哪种类型的值存储在fpw中?以两种方式兼容



if((fpr = fopen(" data"," r"))) != EOF);

if((fscanf(fpr,input,linput,mean))== 0;



你不能'你不知道你在这里错过了一个右括号吗?

你期望多余的分号做什么?


fscanf的假设是什么除了fpr之外,还是

您的任何人都符合标准吗?


承认,你甚至没有尝试编译代码。


fprintf(fpw,"%d \ t%d \ t%d \ n",input,input + linput,mean);

}



%d承诺什么类型的参数?

参数的类型是什么。 />


>
它非常不完整。我有两个流打开一个用于阅读,一个



如果你不知道如何增加计数,你需要从比这更基本的

程序开始。很奇怪你

上面的输入增加没有任何问题。好的,所以你确实有了b $ b麻烦,但至少你知道(幸运的猜测?)使用哪个运营商。



删除电子邮件的del

**发自 http://www.teranews.com **


7月3日上午5:12,Bill Cunningham < nos ... @ nspam.comwrote:


如果没有一些帮助或提示,我不认为我能做到这一点。这是代码

我有。


#include< stdio.h>

#include< stdlib.h> ;


双输入(双输入){

int count = 0,div = 0;

double mean = 0, linput = 0;

FILE * fpr,* fpw;


mean = input + linput / count;



究竟是什么意思?输入+(输入/计数)或(输入+

输出)/计数。你觉得这里有零除问题吗?由于输入

和linput被定义为double,你的平均值等于无穷大。


if((fpw = fopen(" data", " w"))!= EOF);

if((fpr = fopen(" data,r))!= EOF);



下次你应该记得fopen返回FILE *并且

错误检查是针对NULL完成的。

所以if((fpw = fopen(" data,w)))= = NULL);

但是heck;即使是现在它也没意义了(那个;如果你没注意到的话)。

检查NULL然后什么也不做 - 只需继续执行代码。


if((fscanf(fpr,input,linput,mean))== 0;



再次,检查错误,什么都不做这不会编译任何已知的编译器(缺少括号)。


fprintf(fpw,"%d \\ \\ t%d \ t%d \ n",input,input + linput,mean);

}



输入,输入+输出是双打。平均值是双倍且等于

无穷大。%d,如果你看一下doc,则用于签名

整数。 />


这是非常不完整的。我有两个流打开一个用于阅读,一个

用于写作但是我一直在说的计数的,我不知道如何增加它。



我不知道,但是对我来说,你创造了这个混乱的目的。

目的。有更好的方法可以获得乐趣,如果这就是你想要拥有的东西。


I don''t think I can do this without some help or hints. Here is the code
I have.

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

double input(double input) {
int count=0,div=0;
double mean=0,linput=0;
FILE *fpr, *fpw;
mean=input+linput/count;
if ((fpw=fopen("data","w"))!=EOF);
if ((fpr=fopen("data","r"))!=EOF);
if ((fscanf(fpr,input,linput,mean))==0;
fprintf(fpw,"%d\t%d\t%d\n",input,input+linput,mean );
}

It''s very much incomplete. I have two stream open one for reading and one
for writing but the count that I have been speaking of, I don''t know how to
increment it.

Bill

解决方案

Bill Cunningham said:

I don''t think I can do this without some help or hints. Here is the
code
I have.

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

double input(double input) {
int count=0,div=0;

div is a standard C library function prototyped in <stdlib.h>, so this
definition of div "shadows" that function, preventing you from using it.
It is best to avoid using standard C library function names except when
referring to standard C library functions.

double mean=0,linput=0;
FILE *fpr, *fpw;
mean=input+linput/count;
if ((fpw=fopen("data","w"))!=EOF);

You have K&R2. Look up fopen''s return value on failure. You''ve been told
about this before, and quite recently too.

--
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


On Thu, 03 Jul 2008 00:12:03 GMT, "Bill Cunningham" <no****@nspam.com>
wrote:

I don''t think I can do this without some help or hints. Here is the code
I have.

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

double input(double input) {
int count=0,div=0;

White space is free. Use it make your code readable.

double mean=0,linput=0;
FILE *fpr, *fpw;
mean=input+linput/count;

What is the value of count? Are you allowed to divide by that value?

if ((fpw=fopen("data","w"))!=EOF);

Didn''t your compiler generate a diagnostic here? What type and range
of EOF? What type of value does fopen return to be stored in fpw? Are
the two in any way compatible.

if ((fpr=fopen("data","r"))!=EOF);
if ((fscanf(fpr,input,linput,mean))==0;

You couldn''t figure out that you are missing a right parenthesis here?
What do you expect that superfluous semicolon to do?

What are the arguments to fscanf supposed to be? Other than fpr, do
any of yours meet the criteria?

Admit it, you didn''t even try to compile the code.

fprintf(fpw,"%d\t%d\t%d\n",input,input+linput,mean );
}

What type of argument does %d promise? What are the types of your
arguments.

>
It''s very much incomplete. I have two stream open one for reading and one
for writing but the count that I have been speaking of, I don''t know how to
increment it.

If you don''t know how to increment count, you need to start with
programs that are very much more basic than this. Strange that you
didn''t have any trouble incrementing input above. OK, so you did have
trouble but at least you knew (lucky guess?) which operator to use.


Remove del for email
** Posted from http://www.teranews.com **


On Jul 3, 5:12 am, "Bill Cunningham" <nos...@nspam.comwrote:

I don''t think I can do this without some help or hints. Here is the code
I have.

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

double input(double input) {
int count=0,div=0;
double mean=0,linput=0;
FILE *fpr, *fpw;

mean=input+linput/count;

What exactly do you mean? input + (linput / count) or (input +
linput) / count. Do you see a divide by zero problem here? Since input
and linput are define as double, your mean equals infinity.

if ((fpw=fopen("data","w"))!=EOF);
if ((fpr=fopen("data","r"))!=EOF);

May be next time you should remember fopen returns FILE * and the
error checking is done against NULL.
So if ((fpw = fopen("data", "w")) != NULL);
But heck; even now it is meaning-less(that ;, if you didn''t notice).
Check for NULL and then do nothing - just proceed with the code.

if ((fscanf(fpr,input,linput,mean))==0;

Again, check for error and do nothing. And this won''t compile on any
known compiler(missing parenthesis).

fprintf(fpw,"%d\t%d\t%d\n",input,input+linput,mean );
}

input, input + linput are doubles. mean is a double and equals
infinity. %d, if you have a look at the doc, is meant for signed
integers.

It''s very much incomplete. I have two stream open one for reading and one
for writing but the count that I have been speaking of, I don''t know how to
increment it.

I don''t know but it looks like to me that you created this mess on
purpose. There are better ways to have fun if that is what you are
trying to have over here.


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

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