PAT刷题注意

gets函数不可使用

接收一段字符串时(其中可能含有空格),其中getline属于string流,接收一个字符串,遇到‘\n’结束。

简单使用方法如下:

#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    getline(cin, str);
    cout << str;
}

strcmp函数 

strcmp函数是string.h 头文件下用来比较char型数组的字典序大小的,其中当strcmp(str1, str2) 当str1 的字典序小于 str2 时返回一个负数,等于时返回 0, 当str1 大于 str2 时返回一个正数。平时常用的 return strcmp(a.id, b.id) < 0 意为a.id 的字典序列小于 b.id.

猜你喜欢

转载自blog.csdn.net/weixin_35093872/article/details/86551339