New Posts  All Forums:Forum Nav:

[C++] Questions

post #1 of 91
Thread Starter 
Ok, at the moment it's just a single question, but I wanna try and get this program done over the weekend, so I'll probably be back with more.

Is there any way to have a WHILE loop that runs for a certain amount of seconds? I knew there's the Sleep() function; any way to use that with a WHILE loop?

Question 2

Question 3


Almost solved... just keeping the thread here in case of emergencies.
Edited by zodac - 1/28/11 at 10:47am
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
post #2 of 91
I assume you can use the time function and than have a counter track it

Sent from my PC36100 using Tapatalk
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
post #3 of 91
Thread Starter 
And how would I do that?
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
post #4 of 91
will the seconds be predefined? or will you be able to adjust it manually with every run?
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
post #5 of 91
http://www.cplusplus.com/reference/clibrary/ctime/

might help you, if i don't get back in time.
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
post #6 of 91
Here is a link for the code, I dont have time to write it out right now. But just check the system time at the end of the loop and compare in the while loop the time you want it to run and the current time elapsed.

Link on how to use time in C/C++
http://www.java2s.com/Code/C/Develop...meandtimet.htm
Sokar
(20 items)
 
  
CPUMotherboardGraphicsRAM
i7 930 @ 3.75 GHz EVGA x58 3x SLI EVGA 670 4GB 12GB Samsung PC3 12800 
Hard DriveHard DriveHard DriveHard Drive
Cruical M4 WD Caviar Black WD Caviar Black Seagate 
CoolingOSMonitorKeyboard
Custom WC Loop Windows 7 x64 x3 Dell U2312HM I-ROCKS KR-6820E-BK 
PowerCaseMouseMouse Pad
Ultra x3 1000w Danger Den Torture Rack Razer Deathadder Black Razer Goliathis 
AudioAudioAudio
Inifitity P153 Speakers Lepai TA202A Amp Asus Xonar DG 
  hide details  
Reply
Sokar
(20 items)
 
  
CPUMotherboardGraphicsRAM
i7 930 @ 3.75 GHz EVGA x58 3x SLI EVGA 670 4GB 12GB Samsung PC3 12800 
Hard DriveHard DriveHard DriveHard Drive
Cruical M4 WD Caviar Black WD Caviar Black Seagate 
CoolingOSMonitorKeyboard
Custom WC Loop Windows 7 x64 x3 Dell U2312HM I-ROCKS KR-6820E-BK 
PowerCaseMouseMouse Pad
Ultra x3 1000w Danger Den Torture Rack Razer Deathadder Black Razer Goliathis 
AudioAudioAudio
Inifitity P153 Speakers Lepai TA202A Amp Asus Xonar DG 
  hide details  
Reply
post #7 of 91
Thread Starter 
Quote:
Originally Posted by mistax View Post
will the seconds be predefined? or will you be able to adjust it manually with every run?
It'll change every run.

Quote:
Originally Posted by mistax View Post
http://www.cplusplus.com/reference/clibrary/ctime/

might help you, if i don't get back in time.
Quote:
Originally Posted by cbrazeau1115 View Post
Here is a link for the code, I dont have time to write it out right now. But just check the system time at the end of the loop and compare in the while loop the time you want it to run and the current time elapsed.

Link on how to use time in C/C++
http://www.java2s.com/Code/C/Develop...meandtimet.htm
Thanks guys. I'll take a look at those links when I get back home and see if I can make sense of it.
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
post #8 of 91
Code:
#include <iostream>
#include <time.h>

using namespace std;

void wait ( int seconds )
{
  clock_t endwait;
  endwait = clock () + seconds * CLOCKS_PER_SEC ;
  while (clock() < endwait) {}
}


int main()
{

cout << "Enter how many seconds you want this program to run : ";
int runTime;
cin >> runTime;
int oTime = runTime;
while(runTime > 0)
{
cout << "Printing this message for " << oTime << " amount of seconds" << endl;
--runTime;
wait(1);

}
cout << "This program ran for " << oTime << " seconds";


cout << endl;
system("pause");
return 0;
}

/*
Enter how many seconds you want this program to run : 5
Printing this message for 5 amount of seconds
Printing this message for 5 amount of seconds
Printing this message for 5 amount of seconds
Printing this message for 5 amount of seconds
Printing this message for 5 amount of seconds
This program ran for 5 seconds
Press any key to continue . . .
Will run the program for 5 seconds. The wait(1) is the interval inbetween each repeat.
*/
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
post #9 of 91
oh i realize an issue with that code. It will run 10 time in 10 seconds. not X amount of times in 10 seconds. So the while condition has to be change to while the seconds are not less than 0.
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
Precious 2.0
(15 items)
 
My precious
(16 items)
 
 
CPUMotherboardGraphicsRAM
R7 1700 @ 3.9 | 1.35v Asus VI Crosshair Hero EVGA Titan X Hybrid 1514/2000 32GB Gskill DDR4 3200 TridentZ 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB LG 10x Blu-ray Burner Swiftech H220-X Window 8.1 Professional 64Bit 
MonitorMonitorKeyboardPower
Crossover 27inch Acer XB270HU 144Hz G-Sync Deck Legend tactile frost EVGA G2 750W 
CaseMouseAudio
Coolmaster Haf 932 DeathAddder 3.5 Black edition Titanium HD | O2 DAC + AMP 
CPUMotherboardGraphicsRAM
Intel i7-970 @ 4.2 Asus Rampage Formula III Asus DC2 R9 290X @ 1110 24GB of Samsung DDR3 @ 1866 
Hard DriveOptical DriveCoolingOS
Samsung 840PRO 256GB | 2x Samsung F4 2TB | WD 6... LG 10x Blu-ray Burner H70 with 2x GT2150 Window 8.1 Professional 64Bit 
MonitorKeyboardPowerCase
Dell 2407WHFP-HC and Crossover 27Q LED-P Deck Legend tactile frost Seasonic 700watt M12 Coolmaster Haf 932 
MouseMouse PadAudioAudio
DeathAddder 3.5 Black edition TeamLiquid Goliathus Titanium HD AudioEngine A2 and ATH-700D 
CPUGraphicsRAMHard Drive
Intel - 3630QM Nvidia GTX 680M 8 GB DDR3 1600 500GB 7200 | 128 GB Samsung 840 Pro 
Optical DriveOS
DVD RW  Windows 8 Pro 
  hide details  
Reply
post #10 of 91
Thread Starter 
Right, the code you gave in the first post was enough; I only needed a few lines from that and I got it working. Thank you very much.

Now, another question. I'm running this WHILE loop in a thread. In the worker function for the thread, I'm passing through an object called "Input"; one of the members of that object is "seconds", which holds the users choice.

Here the code I've got for the thread:

Code:

threadH[thread] = CreateThread(NULL, 0, worker, &Input[thread], 0, NULL);
 
 
 
 
 
DWORD WINAPI worker(LPVOID Input)
{
 
  //Input.seconds = 1;
 
  cout << "Running for seconds: " << Input.seconds << endl;
  clock_t endwait;
  endwait = clock() + Input.seconds* CLOCKS_PER_SEC;
  while (clock() < endwait)
  {
    cout << "Hello";
  }
 
  cout << "Closing thread..." << endl;

However, it's saying that Input.seconds is undefined. Is there something extra I need to do to get it to recognise the object?
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
Megadoomer
(14 items)
 
Family Computer
(13 items)
 
 
CPUMotherboardGraphicsRAM
Phenom II X6 1090T @ 4.0Ghz ASUS M4A89GTD PRO Sparkle GTS 450 2x4GB G-Skill Sniper 
Hard DriveCoolingOSMonitor
Samsung F1 1TB CM Hyper 212+ Windows 7 Professional x64 Samsung T220 
KeyboardPowerCaseMouse
Logitech MX3000 Laser CM 1000M HAF 922 Logitech VX Revolution 
CPUMotherboardGraphicsRAM
Q6600 Asus PN5-D 750i Evga GTS 250 2x2GB Crucial Ballistix 
Hard DriveOptical DriveOSMonitor
750GB Hitachi Samsung Super Writemaster Windows 7 Professional x64 19" Dell 
PowerCase
Corsair 450VX Antec 900 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming