Hi
How can i write many loops that all run at the same time
Hi
How can i write many loops that all run at the same time
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?
Monday - what a way to spend a seventh of your life
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?
>> 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
One day you will ask what more important to you..
I will say my life..
and You will leave me with even knowing
that
You are my Life (L)
Please..... no C++ code on the C board.... it'll only serve to confuse the new.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
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..
One day you will ask what more important to you..
I will say my life..
and You will leave me with even knowing
that
You are my Life (L)
Use goto to jump through the loops 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.
Last edited by quzah; 11-17-2002 at 12:19 PM.
Hope is the first step on the road to disappointment.
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.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.
Hope is the first step on the road to disappointment.
Multithreading is supported better in such languages as Java and C#
Mr. C: Author and Instructor