how do i perform 2 actions at same time in c++? c++ only seems to run codes one by one sequentially.
how do i perform 2 actions at same time in c++? c++ only seems to run codes one by one sequentially.
You need to look into multithreading. What OS/compiler are you using?
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
multi-threading or multi-process solutions. Its OS and sometimes compiler specific so we'll need more info before helping you.
Dang foiled again by XSquared.
Geez. Thantos. Work on your typing speed.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
The fingers are doing their thing just fine. Its the brain telling them what to type is the slow one today.
o/s = operating system im using? im using windows xp and dev c++, the beta one
Thantos: Just today?
Chobo: Here is an example of threading.
Last edited by XSquared; 04-25-2004 at 07:03 PM.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
does this require knowledge of window programming?
Nope.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
oooooooo this is interesting stuff but a bit advanced for me >.< damn programming hard...
Why do you think that your program needs multithreading?
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
@XSquared: Mainly today
@Chobo: Like all things learning the basics of programming is the hardest part. Multithreading and multiprocess solutions are not a giant step in difficultly once you have those skills. Be patient and you'll get it
If you are a novice in C++, I doubt the program you're making would benifit from threading. There are cases where threads can lower the performance of the program, and you can create serious issues if you do not have experiance with them. Just learn as much as you can first, then decide to use them later.
Do not make direct eye contact with me.
ok -.- i just wanted to add special feature to my program
this program just basically counts down from 20:00 to 0:00. but wat if i want the program to accept an input from the user without interupting the count down? if i use cin, it would stop the count down until the input has been received.Code:#include <windows.h> #include <iostream> #include <conio.h> using namespace std; void gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } int main() { int count; int i, ii; gotoxy(3,0); cout << ":"; for (ii = 20; ii >= 0; ii--) { if (ii >= 10) { gotoxy(1,0); cout << ii; } else { gotoxy(1,0); cout << " "; gotoxy(2,0); cout << ii; } for (i = 60; i >= 0; i--) { if (i >= 10) { gotoxy(4,0); cout << i; Sleep(50); } else { gotoxy(4,0); cout << "0"; gotoxy(5,0); cout << i; Sleep(50); } } } getch(); return 0; }
lookup kbhit(), it will tell you when the user hits a key and using getche() you can read it in one by one.