How to repeat a loop only a certain number of times?

Shoot I feel so frustrated.

Still cant get this code to work.

void setup() {                

  pinMode(13, OUTPUT);     
}




void loop()
// blink an LED the number of times given in the count parameter
{
void blink2(int count) 

 while(count > 0 )                                   // repeat until count is no longer greater than zero
{
 digitalWrite(13, HIGH);
 delay(500);
 digitalWrite(13, LOW);
 delay(500);
 count = count -1;                                  // decrement count 
 }
}

I smuggled in a set up() and a loopvoid () Like you can see in the copied code, but then it is whining about:
sketch_jan03f.cpp: In function 'void loop()':
sketch_jan03f:15: error: expected initializer before 'while'
I don't know what initializer is can't find a single thing about it in the reference guide.

Placed a million brackets on a billion places, swapped the void blink, placed it everywhere I could, before setup, in the setup in the place of void loop, sigh nothing works.

The code of lloyddean works, so thank you for that very much! :grin:

But I still have restless sleeps over why the frigging code from the Arduino cookbook doesn't work. (page 38)
And thx to the succes of mobman, I never felt so dumb before :slight_smile:

Great job mobman btw,

And in other cases I get a count is not declared yet, which make perfect sense if you ask me. But how to declare it ?

Maybe I should just give it a rest. This piece of code.

Thanks all for your previous help!