[C++] If you compile and run

my Grid.cpp source file, does it work or give errors ?

When I try to run the code on repl.it, main segfaults. The best way to find segfaults is to use Valgrind.

I don’t believe that you can include emojii in strings, but that isn’t the only issue here.

Edit: Huh… I guess you can use emojii in code… that is so… wrong…

I was able to compile and run it successfully without any changes (using the 1.board text file in your github repo). I got the following output:

:vertical_traffic_light: ◘ 0 0 0 0
:red_car: ◘ 0 0 0 0
:red_car: ◘ 0 0 0 0
:red_car: ◘ 0 :red_car: :red_car: :red_car:
:red_car: :red_car: :red_car: :red_car::checkered_flag:

Are you having a specific problem? Is this output correct?

This is my output:

Different from yours. I’m on Debian on WSL.

The code you have is the fixed code, I had to find the error manually since the compiler / linter / runtime gave no useful error message.

The C and C++ compilers only check for compilation time errors. That’s why I recommend using valgrind. You will get stack traces with exact line numbers.

Is it hard to integrate into my project ? is it a command line tool ?

Is the syntax something like: valgrind filename.cpp ?

Can I use apt to install it ?

It should be available via Apt. You use valgrind myExe, so in this case valgrind ./Grid

I used apt to install it. not as good as compiling from source though. although I think the docs suggested using one’s package manager.

Valgrind from your distro’s package manager and from source should be basically the same.

Do you know the command off the top of your head for getting the most current version which is 3.16 ? apt gave me 3.14

Apt will give you the latest version that is verified to be compatible with your distro.

ok. all set. lets see how it works. thanks

1 Like

Guess I need to look at the docs to figure this out. but the code seems to work though.

Yep, that’s a good sign. If you take an older version of your code, like from the repl link above, and compile it, then you can see how Valgrind handles errors.

ok. thanks. catch you later

1 Like

What is your OS ? I am on Debian

I am currently on Fedora 32.