0

I am getting an error for my .c code in my vscode application. I have been using vscode for .cpp files till now and it has been working fine with the g++ compiler. Can someone guide me on what modification i need to do to run the .c code now?

Here's the .json file code:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "g++ - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "C/C++: g++ build active file",
        "miDebuggerPath": "/usr/bin/gdb"
    }
]

}

Vinayak
  • 5
  • 1
  • 2
    This error is from your compiler, indicating something wrong with your code. Post that, the .json file is of little value. – yano Dec 25 '21 at 13:20
  • I think my code isn't being compiled properly because i am also getting errors such as : 'main' must return 'int' when i have used void main(). Am i correct? Or is the issue with the code only? – Vinayak Dec 25 '21 at 13:39
  • That's correct, your code is not getting compiled due to errors. The issue is with your code, not the .json file. You need to post your code if you want help. Although, your errors so far sound very fundamental. If you're trying to learn C by guessing and checking, don't. It will be a far better use of your time to get a [good book](https://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list) and/or take a class. – yano Dec 25 '21 at 13:43
  • If you intend to program in C, use a C compiler. `g++` isn't one. Also do not use `void main()`, it's just plain wrong. Do not copy bad code examples from the net. There are lots of those out there. Get yourself a reputable C book. – n. 1.8e9-where's-my-share m. Dec 25 '21 at 14:52
  • 3
    @yano In this case the error (or at least one of the errors) actually could be in a .json file (although probably not *this* .json file). If one uses a wrong compiler, one gets meaningless compilation errors... – n. 1.8e9-where's-my-share m. Dec 25 '21 at 15:04

0 Answers0