help with loop

im sorta having trouble (since i am a total noob) with this piece of code:

for( ;; )
{
system("md %random%");
}

simple piece of code....compiles with the rest of my program perfectly but the problem i am having is how can i make this loop last when 10 random named folder were created or 5 random folders were created basically a break from the loop after 5 times or 10 times or 20 times...i know this can be done using a switch statement or writing the same line of code 10 times but i want to know how to do it in a loop......all help is welcome.

sorta but it didn't work with my code cause my code's intention is to do more then printing and creating files which have strings embedded..thanks anyway..^_^

I found it a bit odd that you were initially using a system call to create a directory. There are functions in C to create directories. system() should almost never be used.

You can instead use mkdir() function to create the directory, however, there are conflicting definitions for it-- mainly because of Microsoft (they claim to use the POSIX mkdir() definition, but they do not).

The solution is to use a macro that auto-detects if it's being compiled on the satanic Microsoft Visual C++ compiler:

In very rare circumstances you can use goto. This is sacrildige and produces hard to follow code, but in rare satanic instances, does the risk of burning in hell for using "goto" provide a significant improvement in performance to justify it: