New Posts  All Forums:Forum Nav:

[C++] Questions - Page 7

post #61 of 91
Thread Starter 
Quote:
Originally Posted by biltong View Post
This thread has made me feel bad about myself, but has been a learning experience and I now have much reading to do
Lol, I started off feeling bad, but there's no way we covered any of this in lectures. So I'm calling it "alternate learning".
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 #62 of 91
Wait, so is this thread [Solved] now?
RAWR
(13 items)
 
Home Server
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-4790k msi z97 gaming 7 gtx 760 4gb 32GB GSkill  
Hard DriveHard DriveCoolingOS
Kingston HyperX 3K 120GB SSD Hitachi 2TB Cooler Master Hyper 212+ Windows 8.1 Pro 
MonitorKeyboardPowerCase
Vizio M492-b2 Logitech Wireless  Corsair HX620 NZXT Phantom White 
Mouse
Logitech Wireless 
  hide details  
Reply
RAWR
(13 items)
 
Home Server
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-4790k msi z97 gaming 7 gtx 760 4gb 32GB GSkill  
Hard DriveHard DriveCoolingOS
Kingston HyperX 3K 120GB SSD Hitachi 2TB Cooler Master Hyper 212+ Windows 8.1 Pro 
MonitorKeyboardPowerCase
Vizio M492-b2 Logitech Wireless  Corsair HX620 NZXT Phantom White 
Mouse
Logitech Wireless 
  hide details  
Reply
post #63 of 91
Thread Starter 
Not yet... I've got the threads going... last thing I'm gonna need to sort out is the following:

I'm gonna have each thread access 2 variables, and change them. I need to make sure no other thread comes in and tries accessing one of the variables at the same time.

I've got to go write the function first, then I'll come back.
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 #64 of 91
Quote:
Originally Posted by zodac View Post
Not yet... I've got the threads going... last thing I'm gonna need to sort out is the following:

I'm gonna have each thread access 2 variables, and change them. I need to make sure no other thread comes in and tries accessing one of the variables at the same time.

I've got to go write the function first, then I'll come back.
That's pretty straight forward in windows/c++.
Check out the part about "critical sections" here: http://www.codeproject.com/KB/threads/sync.aspx
RAWR
(13 items)
 
Home Server
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-4790k msi z97 gaming 7 gtx 760 4gb 32GB GSkill  
Hard DriveHard DriveCoolingOS
Kingston HyperX 3K 120GB SSD Hitachi 2TB Cooler Master Hyper 212+ Windows 8.1 Pro 
MonitorKeyboardPowerCase
Vizio M492-b2 Logitech Wireless  Corsair HX620 NZXT Phantom White 
Mouse
Logitech Wireless 
  hide details  
Reply
RAWR
(13 items)
 
Home Server
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-4790k msi z97 gaming 7 gtx 760 4gb 32GB GSkill  
Hard DriveHard DriveCoolingOS
Kingston HyperX 3K 120GB SSD Hitachi 2TB Cooler Master Hyper 212+ Windows 8.1 Pro 
MonitorKeyboardPowerCase
Vizio M492-b2 Logitech Wireless  Corsair HX620 NZXT Phantom White 
Mouse
Logitech Wireless 
  hide details  
Reply
post #65 of 91
Thread Starter 
I'll take a look at that as soon as I've finished the Foldathon stuff; thanks.
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 #66 of 91
Thread Starter 
Ok, running into a problem in the thread... I've called a function which will return an object into the thread. In the function, I print out all the information of the object, so I know the function is working fine. However, when I try and access that info in the thread, the program crashes.

Here's what I've got:

Code:

Bank* BankResult;
while (clock() < endwait)
  {
    AccountInput = new Account(AccountID, 0, 0);
    BankResult = (Bank*) Data->TreeofBanks.ReturnBankRandom(AccountInput);
    cout << "Thread #" << Data->ThreadID << ". AccountID: " << BankResult->AccountInfo->AccountID;
   } 
It crashes when trying to print out the AccountID.
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 #67 of 91
Crashes with what? segmentation fault?

Are you using a debugger? put a breakpoint on that line and examine the objects. I'm only guessing but I bet something didn't get referenced (either AccountInfo or AccountID is null).

that or you just need to Use BankResult->AccountInfo.AccountID
RAWR
(13 items)
 
Home Server
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-4790k msi z97 gaming 7 gtx 760 4gb 32GB GSkill  
Hard DriveHard DriveCoolingOS
Kingston HyperX 3K 120GB SSD Hitachi 2TB Cooler Master Hyper 212+ Windows 8.1 Pro 
MonitorKeyboardPowerCase
Vizio M492-b2 Logitech Wireless  Corsair HX620 NZXT Phantom White 
Mouse
Logitech Wireless 
  hide details  
Reply
RAWR
(13 items)
 
Home Server
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-4790k msi z97 gaming 7 gtx 760 4gb 32GB GSkill  
Hard DriveHard DriveCoolingOS
Kingston HyperX 3K 120GB SSD Hitachi 2TB Cooler Master Hyper 212+ Windows 8.1 Pro 
MonitorKeyboardPowerCase
Vizio M492-b2 Logitech Wireless  Corsair HX620 NZXT Phantom White 
Mouse
Logitech Wireless 
  hide details  
Reply
post #68 of 91
Thread Starter 
I'm using Dev-C++, and the debugger is saying "Access Violation (Segmentation Fault)" the second I run the code... but the break isn't until near the bottom of my code.

And AccountInfo is a pointer. As I said, in the method, I print out the information of the object before I returned it, so it should all be there.
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 #69 of 91
Where and how(static or dynamic) is AccountID allocated? I'll make an educated guess that you used static allocation inside your function. AccountInfo probably still points to the space where AccountID and anything else associated with that account was stored in the function, but that memory address is now invalid because the memory was deallocated at the end of your function call.
BlackBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 3.6ghz @ 1.35V Gigabyte X38-DS4 ATI 5870 4GB Corsair Dominator 1033Mhz 
Hard DriveOSMonitorKeyboard
Hitachi P7K500 320GB 64-bit Gentoo Linux / 64-bit Vista Ultimate Sceptre X24-WG 24" WUXGA Deck 82-key 
PowerCaseMouse
Corsair 750TX BlackBox (scratch built) Logitech G5 
  hide details  
Reply
BlackBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 3.6ghz @ 1.35V Gigabyte X38-DS4 ATI 5870 4GB Corsair Dominator 1033Mhz 
Hard DriveOSMonitorKeyboard
Hitachi P7K500 320GB 64-bit Gentoo Linux / 64-bit Vista Ultimate Sceptre X24-WG 24" WUXGA Deck 82-key 
PowerCaseMouse
Corsair 750TX BlackBox (scratch built) Logitech G5 
  hide details  
Reply
post #70 of 91
Thread Starter 
Yeah, it is static... But the members of the "bank" object are two pointers... I'd have to change everything if I was going to change that now.
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