If your code compiles without any errors then you indeed need to figure out what's the issue by looking at the code line by line.
You can try to narrow down where things could go wrong by looking at the compiler warnings, if any.
Furthermore, you can add some logging (printing of debug messages) to a file or console to keep track of what your program is doing and where things could break; and just to verify that it is doing whatever it is supposed to do.
You can also use a debugger where you can execute code line by line, check the values of variables, place breakpoints in your code, and many more. Most IDEs have a debugger, OnlineGDB has a debugger too.