首页 > 其他 > 详细

atoi用法

时间:2018-10-28 16:38:54      阅读:140      评论:0      收藏:0      [点我收藏+]

来自头文件 #include <stdlib.h>

atoi()函数用来将字符串转换成整数(int)

int atoi(const char* str) ;

从流中获取字符串:

char* fgets(char*str, int num, FILE*stream );

num: 最大字符个数,包括终止符号

stream:stdin

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

int main()
{
    int i;
    char buffer[256];
    printf("Enter a number:");
    fgets(buffer, 256, stdin);
    i = atoi(buffer);
    printf("The value entered is %d.", i);
    return 0;

}

 

atoi用法

原文:https://www.cnblogs.com/Shinered/p/9865979.html

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