fork download
  1. #include <iostream>
  2. #include<stdio.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,n1;
  8.  
  9. int a=scanf("%d",&n);//storing the input "1" in n also as the no of inputs is 1 "a" will have 1
  10. cout<<a<<" "<<n<<endl;
  11.  
  12. a=scanf("%d %d",&n,&n1);//storing the input "2" in n and "3" in n1 also as the no of inputs is 2 "a" will have 2
  13. cout<<a<<" "<<n<<" "<<n1<<endl;
  14.  
  15. a=scanf("%d",&n);//EOF reached so the previous input of n will remain i.e. 2 and a will have -1
  16. cout<<a<<" "<<n<<endl;
  17. return 0;
  18. }
Success #stdin #stdout 0s 3344KB
stdin
1
2
3
stdout
1 1
2 2 3
-1 2