944,141 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 750
  • C++ RSS
Dec 3rd, 2007
0

C++ for loops

Expand Post »
for the for loop

for ( ; *source!='\0'; source++)

what is the purpose of the semicolon in the for loop ?

thank you!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dsuh06 is offline Offline
15 posts
since Nov 2007
Dec 3rd, 2007
0

Re: C++ for loops

(1) The language specification requires them. (2) they separate initialization, condition, and increment statements.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Dec 3rd, 2007
0

Re: C++ for loops

in a normal loop you would have
for( i = 0; i < n; i++)

but in your code the semicolon simply states that it doesnt matter what the first section( i = 0) is.

[edit] What AD said. lol.
Last edited by people123; Dec 3rd, 2007 at 1:45 am.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
people123 is offline Offline
22 posts
since Oct 2007
Dec 3rd, 2007
0

Re: C++ for loops

thank you!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dsuh06 is offline Offline
15 posts
since Nov 2007
Dec 3rd, 2007
0

Re: C++ for loops

All of the sections are optional, so we sometimes end up with this: for(;;)
Last edited by Ancient Dragon; Dec 3rd, 2007 at 2:04 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005

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: Reading/writing .txt files into an array
Next Thread in C++ Forum Timeline: Overloading Program containing constructors





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


Follow us on Twitter


© 2011 DaniWeb® LLC