Hi
How can i write many loops that all run at the same time :confused:
Printable View
Hi
How can i write many loops that all run at the same time :confused:
I am using "Windows me ".
but, what i mean is how to write c proagram executes many loops at the same time
I repeat because I guess you didnt read the other message, It would be done using threads
the question is not exactly clear, and depends on the application you are writing. It may be possible using nested loop, threads and other ways. What do your loops do?
I want to write C function that draw circle at the center then it divides it to four circles each one move to the one of the four direction at the same time ,so, can you explain how can i use the nested loop?
draw them one at a time
>> How can i write many loops that all run at the same time
Is this what you mean?Code:for(int i = 0, j = 0; i < 100, j < 100; i++, j++)
{
cout << i;
cout << j;
}
Code:for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
cout<<"Enter the "<<i<<j<<" Location: ";
cin>>b[i][j];
}
checkout the code... the nested for loop is used to keep one value... of index of array constant.. for three alteration of the nested loop of variable.. j...
??????any
Please..... no C++ code on the C board.... it'll only serve to confuse the new.
oh, sorry, i'm used to using the stream ways...
I have done the same mistake... as of ... face_master
....
frequently .. moving b/w boards.. caused.. this mistak.. i thought i am posting code on c++ board..:)
Use goto to jump through the loops :D so one loop executes, then jumps to the next, then jumps to the next, then returns to the original so it can increment, then jumps to the next so it can, and so on!
That should work. Why on earth you'd want to do so is beyond me, but that'd work. Or you could just use a single control loop and put all three (or whatever) loop bodies in the same loop. This makes the mose sense, but hey, you just asked how to do it, not if it was a good idea...Code:x = y = z = 0;
dosomething:
while( x < 10 )
{
if( x < 10 )
{
do_something( );
x++;
}
goto dosomething1;
}
dosomething1:
while( y < 10 )
{
if( y < 10 )
{
do_something1( );
y++;
}
goto dosomething2;
}
dosomething2:
while( z < 10 )
{
if( z < 10 )
{
do_something2( );
z++;
}
goto dosomething;
}
[edit]Added an if check to each loop so you could have varried numbers per loop.[/edit]
Quzah.
I think it would be better to do that without gotos and labels and just use loops and the break; statement.
You missed the entire point of the post. Sadly, humor is lost on the majority of you.Quote:
Originally posted by beege31337
I think it would be better to do that without gotos and labels and just use loops and the break; statement.
Quzah.
Multithreading is supported better in such languages as Java and C#
Sadly, some people really write code like that.Quote:
Originally posted by quzah
You missed the entire point of the post. Sadly, humor is lost on the majority of you.
Quzah.
<flame>not-sucking is supported better in such languages as C/C++</flame>Quote:
Originally posted by Mister C
Multithreading is supported better in such languages as Java and C#
:D