#Need help with C++ code

1 messages · Page 1 of 1 (latest)

ebon niche
#

I'm encountering a logical error in the code. The program works in the beginning but then stops working in between. Please help me resolve the error. Thank you.

upbeat cliff
#

What is the error, what are you trying to do

ebon niche
#

there is no syntax error. the program shows console screen. while printing round 1 it shows weapon, allows user to select weapons then when enemy is allowed to pick a weapon, after printing enemy attacking with damage : any value like 3, the program stops working

#

online debugger is giving me this : Program received signal SIGSEGV, Segmentation fault.
0x0000555555555a2c in Player::getHealth (this=0x0) at main.cpp:21
21 return health;
(gdb)

upbeat cliff
#

Do you know what a seg fault is?

ebon niche
#

a little idea, its related to memory ig

upbeat cliff
#

Could you post a screenshot of the code from int main to line 25 here im on mobile so hard to see

ebon niche
#

ok

upbeat cliff
#

Oh, can you go to line 25

#

That's where the error happens

ebon niche
upbeat cliff
#

Oof seg faults are difficult

#

Comment out the if (player.getHealth() ... Line and then just do a std::cout << player.getHealth()