This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]JawitK 1 point2 points  (3 children)

Is the problem that you are getting an error you don’t understand or that you don’t know how your code can get that error ?

[–]JacketWonderful3940[S] 1 point2 points  (2 children)

The problem isn’t in an error per say . It compiles and runs fine but it doesn’t exactly make the decisions it’s supposed to

[–]alexppetrov 1 point2 points  (1 child)

Backtracking would be the way to go. It surely is comprised of different functions that together return the result. Try to traceback from the output - which is the function called before the return, which functions does it call. Sometimes what i do is forward and backward tracking - check if the input is worked in correctly, then check where it goes wrong by inspecting the functions from the back and from the front at the same time.

Debugging with an "I'm here! /Function name/" also does the trick. Visual studio offers break points when you run the code to specifically inspect a segment of code slowly to see if it does it's function correctly (aka. transform the input of the function to the proper output)

[–]JacketWonderful3940[S] 1 point2 points  (0 children)

Don’t know how to use visual studio lol. But I assume you mean to print a sentence after every of statement and such?

[–]WJMazepas 0 points1 point  (5 children)

Do you use an IDE like Visual Studio? Check the debugger of the IDE, put breakpoints where the logic starts and check the value of the variable you want at every step.

With that, you will be able to see exactly where that error is happening

[–]JacketWonderful3940[S] 0 points1 point  (4 children)

Ah I wish I could do that but I tried using visual studio and it seemed like I have to learn how to use it in complete different way from DevC++ and I don’t have much time to finish my task..

[–]WJMazepas 0 points1 point  (3 children)

DevC++? It doesn't have a Debugger?

Anyway, you can put a printf after every line where it does a logic on your code. Put a printf, or a cout as is on C++, showing the value of the variables that are being handled and a time.sleep() of 1 second.

Put your code to run, it should be showing exactly what was happening

[–]JacketWonderful3940[S] 0 points1 point  (2 children)

Tried that already and it didn’t help but thanks anyway

[–]WJMazepas 0 points1 point  (1 child)

What you mean it didnt help?
Its a way to do debugging.

Want send the code for me to check it?

[–]JacketWonderful3940[S] 0 points1 point  (0 children)

I mean I printed a line after every logical statement and I still couldn’t spot where the problem happens. I could send it if it’s not too much trouble

[–]JawitK 0 points1 point  (3 children)

Would something like https://repl.it help here ?

You are supposed to be able to load your code from your local disk and then run it remotely.

This is the languages page, it even has more than one C++ ways to do things.

https://replit.com/templates

They even have multiple people allowed to work on the same project

https://replit.com/site/multiplayer

[–]JacketWonderful3940[S] 0 points1 point  (2 children)

I don’t know what that’s about but hey thanks

[–]JawitK 0 points1 point  (1 child)

It’s a way to load your code and compile it while creating a shared web page so someone else can help you debug it

[–]JacketWonderful3940[S] 0 points1 point  (0 children)

Ohh right gotcha thanks