C档 [英] C file

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

问题描述

#include< stdio.h>


main(){

char * cap;

printf(" ;输入代码 - ");

fflush(stdout);

fgets(上限,100,标准差);

printf(上限) ;}


现在这看起来好多了。 Decal指向char的指针似乎是
是fgets第一个参数的默认值。这个编译甚至没有一个

投诉。因此,如果有人输入的内容是

是200个字符长。会有错误但没有缓冲区溢出?


Bill

解决方案

Bill Cunningham写道:


#include< stdio.h>


main(){

char * cap ;

printf(" Enter code-");

fflush(stdout);

fgets(cap,100,stdin);



上限点在哪里?


-

Ian Collins。




" Ian Collins" < ia ****** @ hotmail.comwrote in message

news:5q ************ @ mid.individual.net ...


Bill Cunningham写道:


> #include< stdio.h>
main(){
char * cap;
printf(" Enter code-");
fflush(stdout);
fgets(cap,100,stdin);



上限点在哪里?


-

Ian Collins。



到此文件中的char类型。


Bill


< blockquote> Bill Cunningham写道:


" Ian Collins" < ia ****** @ hotmail.comwrote in message

news:5q ************ @ mid.individual.net ...


> Bill Cunningham写道:


>> #include< stdio.h>

main(){
char * cap;
printf(" Enter code-");
fflush(stdout);
fgets(cap,100 ,标准输入);


上限点在哪里?



*请*不要引用签名。


>

到此文件中的类型字符。



不,它未经初始化。


-

Ian Collins。


#include <stdio.h>

main(){
char *cap;
printf("Enter code-");
fflush(stdout);
fgets(cap,100,stdin);
printf(cap);}

Now this seems to work much better. Decalring a pointer to a char seems to
be the default of fgets first parameter. This compile without even a
complaint by the compile for a cast. So if someone entered something that
was 200 chars long. There would be an error but not a buffer overrun?

Bill

解决方案

Bill Cunningham wrote:

#include <stdio.h>

main(){
char *cap;
printf("Enter code-");
fflush(stdout);
fgets(cap,100,stdin);

Where does cap point?

--
Ian Collins.



"Ian Collins" <ia******@hotmail.comwrote in message
news:5q************@mid.individual.net...

Bill Cunningham wrote:

>#include <stdio.h>

main(){
char *cap;
printf("Enter code-");
fflush(stdout);
fgets(cap,100,stdin);


Where does cap point?

--
Ian Collins.

To a type char in this file.

Bill


Bill Cunningham wrote:

"Ian Collins" <ia******@hotmail.comwrote in message
news:5q************@mid.individual.net...

>Bill Cunningham wrote:

>>#include <stdio.h>

main(){
char *cap;
printf("Enter code-");
fflush(stdout);
fgets(cap,100,stdin);

Where does cap point?

*Please* don''t quote signatures.

>
To a type char in this file.

No, it is uninitialised.

--
Ian Collins.


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

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