码迷,mamicode.com
首页 > 编程语言 > 详细

c++ string

时间:2016-11-04 01:49:01      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:cst   blog   find   ber   ios   return   first   char   cout   

#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

标签:cst   blog   find   ber   ios   return   first   char   cout   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!