fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. string str ("Test string");
  6. for (int index = 0, auto it = str.begin(); it < str.end(); ++it, ++index)
  7. cout << index << *it;
  8. return 0;
  9. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:6:22: error: expected unqualified-id before ‘auto’
  for (int index = 0, auto it = str.begin(); it < str.end(); ++it, ++index)
                      ^~~~
prog.cpp:6:22: error: expected ‘;’ before ‘auto’
prog.cpp:6:42: error: could not convert ‘it’ from ‘__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >’ to ‘bool’
  for (int index = 0, auto it = str.begin(); it < str.end(); ++it, ++index)
                                          ^
prog.cpp:6:59: error: expected ‘)’ before ‘;’ token
  for (int index = 0, auto it = str.begin(); it < str.end(); ++it, ++index)
                                                           ^
prog.cpp:6:63: error: ‘it’ was not declared in this scope
  for (int index = 0, auto it = str.begin(); it < str.end(); ++it, ++index)
                                                               ^~
prog.cpp:6:69: error: ‘index’ was not declared in this scope
  for (int index = 0, auto it = str.begin(); it < str.end(); ++it, ++index)
                                                                     ^~~~~
stdout
Standard output is empty