首页 > 编程语言 > 详细

C语言 gets

时间:2020-02-27 19:18:26      阅读:69      评论:0      收藏:0      [点我收藏+]

C语言 gets

#include <stdio.h>
char *gets(char *s);

功能:从标准输入读入字符,并保存到s指定的内存空间,直到出现换行符或读到文件结尾为止。

参数:

  • s:字符串首地址

返回值:

  • 成功:读入的字符串
  • 失败:NULL

案例

技术分享图片
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(void)
{

    // gets()
    // 通过键盘获取一个字符串
    // 接受字符串可以带空格
    char ch1[100];
    gets(ch1);
    printf("%s\n", ch1);

    return 0;
}
gets 使用案例

 

C语言 gets

原文:https://www.cnblogs.com/xiangsikai/p/12373646.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!