943,108 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 332
  • C++ RSS
Feb 8th, 2010
0

Why doesn't this work?

Expand Post »
It doesn't compile, why?

C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. for(int cnt1 = 0, int cnt2 = 10; cnt1<10; ++cnt1, --cnt2)
  10. {
  11. cout << cnt1 << "--------Hello!---------" << cnt2 << endl;
  12. }
  13.  
  14. system("PAUSE");
  15. }
Reputation Points: 10
Solved Threads: 0
Light Poster
invisi is offline Offline
27 posts
since Aug 2009
Feb 8th, 2010
0
Re: Why doesn't this work?
Sorry solved the problem myself
Reputation Points: 10
Solved Threads: 0
Light Poster
invisi is offline Offline
27 posts
since Aug 2009
Feb 8th, 2010
0
Re: Why doesn't this work?
Good. Cuz the answer would've been "Because you wrote it wrong"

Without details, and our lack of psychic ability, what else could we say?
Moderator
Reputation Points: 3275
Solved Threads: 886
Posting Sage
WaltP is offline Offline
7,699 posts
since May 2006
Feb 8th, 2010
0
Re: Why doesn't this work?
Click to Expand / Collapse  Quote originally posted by WaltP ...
Without details, and our lack of psychic ability, what else could we say?
I could say:
1. the declaration of the variables in the loop is wrong, there's an int to many.

2. <cstdlib> has to be included for system()
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Feb 8th, 2010
0
Re: Why doesn't this work?
wrong usage of for loop
Reputation Points: 10
Solved Threads: 1
Newbie Poster
poorann is offline Offline
5 posts
since Feb 2010
Feb 8th, 2010
1
Re: Why doesn't this work?
back....
Moderator
Reputation Points: 3275
Solved Threads: 886
Posting Sage
WaltP is offline Offline
7,699 posts
since May 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Semi-Equality in C++
Next Thread in C++ Forum Timeline: function





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


Follow us on Twitter


© 2011 DaniWeb® LLC