Error[8]: Undefined offset: 37, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

fgets() 的原型为:

include

char *fgets(char *s, int size, FILE *stream);

有三个参数。它的功能是从 stream 流中读取 size 个字符存储到字符指针变量 s 所指向的内存空间。它的返回值是一个指针,指向字符串中第一个字符的地址。
下面写一个程序:

# include 
int main(void)
{
char str[20]; /*定义一个最大长度为19, 末尾是'printf'的字符数组来存储字符串*/
("请输入一个字符串:");fgets
(,str7 ,stdin );/*从输入流stdin即输入缓冲区中读取7个字符到字符数组str中*/ printf
("%s\n",) str;return
0 ;}
[+++]

输出结果是:
请输入一个字符串:i love you
i love

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 29, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
C语言fgets函数用法_C_内存溢出

C语言fgets函数用法

C语言fgets函数用法,第1张

fgets() 的原型为:

include

char *fgets(char *s, int size, FILE *stream);

有三个参数。它的功能是从 stream 流中读取 size 个字符存储到字符指针变量 s 所指向的内存空间。它的返回值是一个指针,指向字符串中第一个字符的地址。
下面写一个程序:

# include 
int main(void)
{
char str[20]; /*定义一个最大长度为19, 末尾是'printf'的字符数组来存储字符串*/
("请输入一个字符串:");fgets
(,str7 ,stdin );/*从输入流stdin即输入缓冲区中读取7个字符到字符数组str中*/ printf
("%s\n",) str;return
0 ;}

输出结果是:
请输入一个字符串:i love you
i love

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/789214.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-05
下一篇 2022-05-05

发表评论

登录后才能评论

评论列表(0条)

保存