我的do/while循环有什么问题?

wfb*_*ale 0 conditional objective-c while-loop conditional-statements

以下代码给出了一个错误:"expected';' 在'{'token"之前.谁能明白为什么?

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

小智 5

是的,你有两个括号.摆脱那些.另外放一个分号.

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