zoukankan      html  css  js  c++  java
  • C++ isdigit()函数,参数只能是字符类型

    /*
        有关isdigit()函数,参数只能是字符类型
    */
    #include<iostream>
    #include<cctype>

    using namespace std;

    int main()
    {
        /* 无论输入什么数字,结果都是非数字
        int a;
        cout << "输入一个数字,非数字自动退出" << endl;
        while (cin >> a)
        {
            if (isdigit(a))
                cout << "是数字";
            else
                cout << "不是数字";
        }
        */

       //要正确使用需要使用字符
        char a;
        cout << "输入一个数字,'#'退出" << endl;
        while (cin >> a && a != '#')
        {
            if (isdigit(a))
                cout << "是数字" << endl;
            else
                cout << "不是数字" << endl;
        }
        return 0;
    }
  • 相关阅读:
    mysqllog
    清理:db上面的过期的binlog,释放磁盘空间。 (转)
    linux下shell命令trap
    mvc
    uci随笔
    luci 随笔
    shell脚本 整数比较
    lua学习
    OPENWRT make menuconfig错误之一
    openwrt 中make的使用
  • 原文地址:https://www.cnblogs.com/hemage/p/13625531.html
Copyright © 2011-2022 走看看