fork download
  1. #include <iostream>
  2.  
  3. int i = 20;
  4.  
  5. int main() {
  6. int i = 10;
  7. int i = 20; // only possible if your compiler/compiler-mode is "stupid".
  8. for (int i = 0; i < 5; ++i) {
  9. std::cout << "loop i = " << i << std::endl;
  10. }
  11. std::cout << "i = " << i << std::endl;
  12. }
  13.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:7:13: error: redeclaration of ‘int i’
         int i = 20; // only possible if your compiler/compiler-mode is "stupid".
             ^
prog.cpp:6:13: error: ‘int i’ previously declared here
         int i = 10;
             ^
stdout
Standard output is empty