首页 > 编程语言 > 详细

c++ string

时间:2016-11-04 01:47:30      阅读:181      评论:0      收藏:0      [点我收藏+]
#include <iostream> 
#include <cctype>
#include <string>
using namespace std;

int main() { 

    char next;
    string message="All good!\n";
    cin.get(next);

    while (cin.get(next) && (next != \n)) {
        if (! isdigit(next)) 
            message = "There‘s a non-number in here! \n";
    }
    cout << message << endl;

    return 0; 
}



#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

int main() { 

    char next;
    string setofnums = "0123456789";
    string email;
    cin >> email;

    if (email.find_first_not_of(setofnums) != string::npos) 
        cout << "There‘s a non-number in here! \n";
    else
        cout << "All good!\n";

    return 0; 
}

 

c++ string

原文:http://www.cnblogs.com/minmsy/p/6028672.html

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