一个关于关闭同步流的问题
  • 板块学术版
  • 楼主__newbie__
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/10/19 20:07
  • 上次更新2023/10/27 06:52:18
查看原帖
一个关于关闭同步流的问题
614884
__newbie__楼主2022/10/19 20:07

如下这段代码(1.in里存有一个字符串 abcdeabcde),为什么在关闭同步流之前读入一个数字,后面读入的字符串就是空的(1.out里面什么都没有)?

#include <bits/stdc++.h>

using namespace std;

int n;

string s;

int main() {
	freopen("1.in", "r", stdin);
	freopen("1.out", "w", stdout);
	cin >> n;
	ios :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> s;
	cout << s;
	return 0;
}
2022/10/19 20:07
加载中...