I'm currently learning C and I'm stuck on a problem. I have to write a program that returns the sum of a submatrix given two coordinates in an m x n matrix. I wrote the code in VS Code, and while it runs fine on an online C compiler, I'm having issues in VS Code. When I try to run it, I just see a message about the directory but no output from my program. It shows the running command in the output screen but exits with code 1 after a few seconds. I've entered my code but I need help figuring out why it's not working in VS Code!
3 Answers
First things first, try using a different folder for your files instead of the Desktop. It's a special folder and can cause issues. Create a normal folder directly on the C: drive without spaces or special characters.
Also, check if there are any compilation errors. You didn't mention any when you posted this, so make sure to look into that.
And finally, make sure you're looking at the right output tab. Sometimes the terminal and output tabs get confused, and you might be checking the wrong one!
P.S. Try to use code blocks for your entire program in the forum; it makes it easier to read!
Do you have GCC installed on Windows? If not, it might be best to install 'Visual Studio' along with the C/CPP components, or just the 'Visual Studio Build Tools' if you don't want the IDE. You can run 'code' from the Visual Studio Development Prompt, which sets everything up correctly for compiling with the Microsoft Visual compiler in the embedded terminal in VS Code. That could resolve your issues!
This is exactly why I recommend using a proper IDE like Visual Studio instead of VS Code for C programming. It has built-in support for debugging and better handling of compiler issues.
I get that! But can you clarify what exactly I'm missing with VS Code?
Thanks for the tips! I'll definitely try using a different folder.