0

consider following program

string hr = "hackerrank";
for(auto &c: hr){
        cout<<c;
}

this code runs perfectly fine on hackerrank but whenever I try to compile this program on my ubuntu 16.4.1 using g++ compiler, it shows following error,

error: ISO C++ forbids declaration of ‘c’ with no type [-fpermissive]
for(auto &c: hr){

why is it showing error on g++ compiler but not on HackerRank ?

PS: I tried going through all questions where this error is discussed. but I couldn't find an answer. If you find a similar question then let me know.

Ani
  • 2,848
  • 2
  • 24
  • 34

0 Answers0