This code ok or should i do diffo way?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 14
Reputation: Code Shark is an unknown quantity at this point 
Solved Threads: 0
Code Shark Code Shark is offline Offline
Newbie Poster

This code ok or should i do diffo way?

 
0
  #1
Oct 27th, 2008
  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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

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

 
0
  #2
Oct 27th, 2008
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.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

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

 
0
  #3
Oct 27th, 2008
I agree with thwee -- the for(;;) is nonsensical. If you are trying to keep your program window open, just do the get()
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 86
Reputation: gregorynoob is an unknown quantity at this point 
Solved Threads: 5
gregorynoob gregorynoob is offline Offline
Junior Poster in Training

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

 
0
  #4
Oct 27th, 2008
Originally Posted by Code Shark View Post
As title says is this code ok or should i do it another way?
depends on what it's supposed to do
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC