DEV Community

Discussion on: For Loop in different programming languages

Collapse
 
codemouse92 profile image
Jason C. McDonald

Very nice, but it's missing my favorite, C++!

std::string str = "hello";
for (int i=0; i < str.length(); ++i)
{
    std::cout << str[i] << std::endl;
}

Note I'm using the prefix increment in my for loop, for pedantic (and habitual) performance reasons. (In reality, your compiler usually optimizes this itself.)

Given more time later, I'll come back and add the other two.