#include <iostream>
#include<string>

int main() {    
    for(int i = 0; i <= 10; ++i) {
          std::string triangle(i, '*');
          std::cout << triangle << std::endl;
    }
    
    for(;;) std::cin.get();
    
    return 0;
}

As title says is this code ok or should i do it another way?

Member Avatar for iamthwee

If you understand it (i.e you didn't copy it) and it does as intended then I don't see why not.

The end part <for(;;) std::cin.get();> seems a bit retarded though.

I agree with thwee -- the for(;;) is nonsensical. If you are trying to keep your program window open, just do the get()

As title says is this code ok or should i do it another way?

depends on what it's supposed to do :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.