I am new to MacOS and I am trying to set up a programming environment and my IDE is Visual Studio Code. When a program launches it, by default it prints on output. However, a request for data collection fails. The online solution I found for this is code output through the terminal, but now nothing is displayed in the terminal.
I am posting it here instead of reporting an error since I am not sure if the error is mine or a program.
Here is a simple code I'm trying to run:
#include <iostream>
int main()
{
int i;
std::cout << "Enter a number: ";
std::cin >> i;
std::cout << "\n" << i;
return 0;
}
When passing through the output, it displays the first part, then a failure when prompted for input. When passing through the terminal, the terminal displays only "cd" (directory location) "& g ++ main.cpp -o main & &" (directory location) "main" and nothing else.
Below are my tasks. json and launch.json:
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"taskName": "c++ test program",
"type": "shell",
"command": "g++",
"args": [
"-g", "main.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
}
]
}
The only parameter that has been changed will be "code-runner.runInTerminal", which is set to true.