943,867 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 498
  • C++ RSS
Oct 27th, 2008
0

This code ok or should i do diffo way?

Expand Post »
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include<string>
  3.  
  4. int main() {
  5. for(int i = 0; i <= 10; ++i) {
  6. std::string triangle(i, '*');
  7. std::cout << triangle << std::endl;
  8. }
  9.  
  10. for(;;) std::cin.get();
  11.  
  12. return 0;
  13. }

As title says is this code ok or should i do it another way?
Last edited by Code Shark; Oct 27th, 2008 at 8:51 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Code Shark is offline Offline
14 posts
since Jul 2008
Oct 27th, 2008
0

Re: This code ok or should i do diffo way?

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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Oct 27th, 2008
0

Re: This code ok or should i do diffo way?

I agree with thwee -- the for(;;) is nonsensical. If you are trying to keep your program window open, just do the get()
Moderator
Reputation Points: 3278
Solved Threads: 892
Posting Sage
WaltP is offline Offline
7,718 posts
since May 2006
Oct 27th, 2008
0

Re: This code ok or should i do diffo way?

Click to Expand / Collapse  Quote originally posted by Code Shark ...
As title says is this code ok or should i do it another way?
depends on what it's supposed to do
Reputation Points: 12
Solved Threads: 5
Junior Poster in Training
gregorynoob is offline Offline
86 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Test Casing
Next Thread in C++ Forum Timeline: Array of Pointers to Objects





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC