开发者

What is wrong with my do/while loop?

开发者 https://www.devze.com 2023-01-05 06:13 出处:网络
the following code gives me an error of: \"expected \';\' before \'{\' token\". can anyone see why开发者_如何学运维?

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

精彩评论

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