views:

81

answers:

2

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…
}
+5  A: 

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);
thyrgle
I think I need more coffee, haha, thanks for the help!
TaoStoner
+1  A: 

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?

Anon.