for the for loop

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

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

thank you!

Recommended Answers

All 4 Replies

(1) The language specification requires them. (2) they separate initialization, condition, and increment statements.

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.

thank you!!

All of the sections are optional, so we sometimes end up with this: for(;;)

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.