这有什么问题。 (文件) [英] What is wrong with this. (files)

查看:94
本文介绍了这有什么问题。 (文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好。我很尴尬地问这个,但我似乎无法获得

文件。我不知道问题是什么。有什么东西

错了:(文件相关)


#include< stdio.h>

main() {

FILE * pfsin;

pfsin = fopen(" msm.pfs"," r");

char mystr [100 ];


fscanf(pfsin,"%s",mystr);

fclose(pfsin);

}


谢谢你的高级,但是我看过几个看起来像这样的代码的例子

EXACLTY这样,出于某些原因我的编译器给了我

rediculus错误。

Nori

解决方案

没有********* @ gmail.com 写道:


好的。我很尴尬地问这个,但我似乎无法获得
文件。我不知道问题是什么。这有什么不对吗:(文件相关)

#include< stdio.h>
main(){
FILE * pfsin;


pfsin = fopen(" msm.pfs"," r");
char mystr [100];


C89上面的两行代码无序。

还有其他问题,

但是让我们看看我们是否可以让你先编译。

fscanf(pfsin,"%s",mystr);
fclose(pfsin);
}

感谢高级,
但是我看到了几个看起来像这样的EXACLTY的代码示例,并且出于某种原因我的编译器给了我
rediculus错误。




-

pete


2006年5月16日05:13:58 - 0700,no ********* @ gmail.com

< no ********* @ gmail.com>写道:

好的。我很尴尬地问这个,但我似乎无法获得
文件。我不知道问题是什么。这有什么不对吗:(文件相关)

#include< stdio.h>
main(){
FILE * pfsin;
pfsin = fopen(" msm.pfs"," r");
char mystr [100];

fscanf(pfsin,"%s",mystr);
fclose(pfsin);
}
谢谢你的高级,但是我看过几个看起来像这样的EXACLTY代码的例子,由于某种原因,我的编译器是给我
rediculus错误。
Nori




最有可能的错误不是rediculus。 (原文如此)。快速浏览

您的代码会显示以下内容:


(a)main()的声明错误。

( b)C89不允许将声明与其他声明混合。

(c)不检查fopen()返回状态。

(d)使用幻数 100.

(e)调用fscanf()时缓冲区溢出的风险。

(f)缺少返回语句。


[否********* @ gmail.com"写道:


好的。我很尴尬地问这个,但我似乎无法让文件工作。我不知道问题是什么。这有什么问题:(文件相关)

#include< stdio.h>
main(){
FILE * pfsin;
pfsin = fopen(" msm.pfs"," r");
char mystr [100];

fscanf(pfsin,"%s",mystr); <感谢高级,但我已经看到了几个代码看起来像这样的EXACLTY的例子,并且出于某种原因,我的编译器是
给我一个rediculus错误。




是的,这有点不对劲。阅读深红色

彩色iculus错误信息可能会给你一个线索。我可以看到

至少三个明显的错误,以及至少两个更多的战术错误。


-

如果你想通过groups.google.com发布一个后续内容,不要使用

破坏的回复链接在文章的底部。点击

" show options"在文章的顶部,然后点击

回复在文章标题的底部。 - Keith Thompson

更多详细信息:< http://cfaj.freeshell.org/google/>

另见< http://www.safalra .com / special / googlegroupsreply />


Okay. I''m quite embarased to be asking this but I cannot seem to get
files to work. I don''t know what the problem is. Is there something
wrong with this: (file related)

#include <stdio.h>
main() {
FILE *pfsin;
pfsin = fopen("msm.pfs", "r");
char mystr[100];

fscanf(pfsin, "%s", mystr);
fclose(pfsin);
}

Thanks in advanced, but I have seen several examples of code that looks
EXACLTY like this, and for some reason my compiler is giving me
rediculus errors.
Nori

解决方案

no*********@gmail.com wrote:


Okay. I''m quite embarased to be asking this but I cannot seem to get
files to work. I don''t know what the problem is. Is there something
wrong with this: (file related)

#include <stdio.h>
main() {
FILE *pfsin;
pfsin = fopen("msm.pfs", "r");
char mystr[100];
The above two lines of code are out of order for C89.
There''s other problems too,
but let''s see if we can get you compiling first.
fscanf(pfsin, "%s", mystr);
fclose(pfsin);
}

Thanks in advanced,
but I have seen several examples of code that looks
EXACLTY like this, and for some reason my compiler is giving me
rediculus errors.



--
pete


On 16 May 2006 05:13:58 -0700, "no*********@gmail.com"
<no*********@gmail.com> wrote:

Okay. I''m quite embarased to be asking this but I cannot seem to get
files to work. I don''t know what the problem is. Is there something
wrong with this: (file related)

#include <stdio.h>
main() {
FILE *pfsin;
pfsin = fopen("msm.pfs", "r");
char mystr[100];

fscanf(pfsin, "%s", mystr);
fclose(pfsin);
}

Thanks in advanced, but I have seen several examples of code that looks
EXACLTY like this, and for some reason my compiler is giving me
rediculus errors.
Nori



Most likely the errors are not "rediculus" (sic). A quick glance at
your code brings up the following:

(a) Wrong declaration for main().
(b) C89 does not allow mixing declarations with other statements.
(c) No check for fopen() return status.
(d) Use of "magic number" 100.
(e) Risk of buffer overflow in call to fscanf().
(f) Missing return statement.


"no*********@gmail.com" wrote:


Okay. I''m quite embarased to be asking this but I cannot seem to
get files to work. I don''t know what the problem is. Is there
something wrong with this: (file related)

#include <stdio.h>
main() {
FILE *pfsin;
pfsin = fopen("msm.pfs", "r");
char mystr[100];

fscanf(pfsin, "%s", mystr);
fclose(pfsin);
}

Thanks in advanced, but I have seen several examples of code that
looks EXACLTY like this, and for some reason my compiler is
giving me rediculus errors.



Yes, there is something wrong with that. Reading the crimson
colored iculus error messages may give you a clue. I can see at
least three glaring errors, and at least two more tactical errors.

--
"If you want to post a followup via groups.google.com, don''t use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


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

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