关于cin.get()函数的问题
cin.get()函数使用后,程序运行起来一输入就退出,不用get()函数,改成cin>>又正常。程序代码:
#include <iostream> using namespace std; void main() { char a[10], b[10]; cout << "请输入字符序列a:"; cin.get(a, 10); cout << "请输入字符序列b:"; cin.get(b, 10); char *pa, *pb, *p; pa = a; pb = b; p = NULL; while (*pa == *pb) { pa++; pb++; } if (int(*pa) > int(*pb)) p = a; else p = b; cout << "序列a:" << a << "\n序列b:" << b << endl; cout << "其中较大的序列为" << p; }