1、cerr
freopen cout输出到文件内时,cerr能输出到控制台显示
2、cin.getline()
defalut -> '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #include<bits/stdc++.h> using namespace std; int main(){ //IOS; //freopen("a.txt","r",stdin); char a[1000]; while(cin.getline(a,23333,',')){ cout<<a<<endl; } return 0; } 输出: 123,124,124,124, 123 124 124 124View Code
3、cin.peek()提前读入一个字符,但不从输入流中去掉
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #include<bits/stdc++.h> using namespace std; int main(){ //IOS; //freopen("a.txt","r",stdin); ; if(isdigit(cin.peek())){ int a; cin>>a; cout<<a<<endl; } else{ char a[10]; cin>>a; cout<<a<<endl;; } return 0; }View Code