开发者

What is wrong with my do/while loop?

the following code gives me an error of: "expected ';' before '{' token". can anyone see why开发者_如何学运维?

do {
  r = rand() % numElements;
} while ([questionsShown containsObject:r] && myCount < numElements) {
  //code here…
}


Yes, you have two brackets after your while. Get rid of those. Plus place a semicolon.

do { 
r = rand() % numElements; 
// code should go here
} while ([questionsShown containsObject:r] && myCount < numElements);


The structure of a do/while loop is so:

do {
    //code
} while (condition);

//more code

(Note the semicolon at the end).

Your code looks like:

do {
    r = rand() % numElements;
} while ([questionsShown containsObject:r] && myCount < numElements)

{
    //code here...
}

See how you're missing a semicolon?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜