标准输入流

版权声明:lixiang666 https://blog.csdn.net/weixin_43838785/article/details/90647045
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
int main()
{
	cout << "first call" << cin.get() << endl;
	char ch;
	cin.get(ch);
	cout << "second call" << ch << endl;
	char str[10];
	cin.get(str, 8, 'T');
	cout << "third call" << str << endl;
	system("pause");
	return 0;
}

在这里插入图片描述

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
int main()
{
	int line, max = 0;
	char str1[100], str2[100];
	cout << "please input some strings:" << endl;
	while (cin.getline(str1, 100))
	{
		line = cin.gcount();
		if (line > max)
		{
			max = line;
			strcpy(str2, str1);
		}
	}
	cout << endl;
	cout << str2 << endl;
	cout << max << endl;
	system("pause");
	return 0;
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43838785/article/details/90647045