0

下面的代码给了我一个错误:“expected”;'在'{'token'之前。谁能看到为什么?我的do/while循环出了什么问题?

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

回答

5

是的,你有一段时间后有两个括号。摆脱那些。再加上一个分号。

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

我想我需要更多的咖啡,哈哈,感谢您的帮助! – wbarksdale 2010-07-02 01:18:43

1

一个做的结构/ while循环是这样:

do { 
    //code 
} while (condition); 

//more code 

(注意在最后的分号)。

代码如下:

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

{ 
    //code here... 
} 

看你是如何丢失的分号?