VS code execute.cpp file terminates the terminal with error code 1.

Asked 2 years ago, Updated 2 years ago, 49 views

Hi. I asked Stackoverflow, but...It's a Korean question, so I'll post it here crying My project folder is as follows.

test.cpp is a very simple code.

#include <iostream>
#include <fstream>
#include <istream>
#include <sstream>
#include <string>
#include <list>
#include <filesystem>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

vector<int> test(vector<int> arr){
    arr.push_back(3);
    return arr;
};

int main(){
    vector<string> arr ={"apple", "banana", "apple"};
    map<string, int> map;

    arr.erase(unique(arr.begin(), arr.end()), arr.end());
    for (int i=0; i<arr.size(); i++){
        cout<<arr[i]<<"\t";
    }
    printf("\n\n");
    return 0;
};

There is no error in build, but if you press execute, the error appears as follows:

> Executing task in folder Backtest: cmd/C "C:\Users\hyemi\OneDrive\Desktop\Backtest/test.exe" <

'C:\Users\hyemi\OneDrive\Background' is an internal or external command, an executable program, or
This is not a batch file.
The terminal process "C:\WINDOWS\System32\cmd.exe /d /ccmd /C "C:\Users\hyemi\OneDrive\Desktop\Backtest/test.exe" terminated with exit code: 1.

tasks.json is as follows.

{
    "version" : "2.0.0" ,
    "runner" : "terminal" ,
    "type" : "shell" ,
    "echoCommand" : true ,
    "presentation" : {
        "reveal" : "always"
   },
   "tasks": [
       //C++ Compiling
       {
           "label" : "c++ build" ,
            "command" : "c:/MinGW/bin/g++.exe" ,
            "args" : [
                "${fileDirname}/${fileBasenameNoExtension}.cpp" ,
                "-g" ,
                "-o" ,
                "${fileDirname}/${fileBasenameNoExtension}.exe",
                "-I", "C:/C++_lib/boost_1_77_0",
                "-L", "C:/C++_lib/boost_1_77_0/libs"

            ],
           "group": "build",
           //Error reflected in editor when compiling
           //Note: https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher
           "problemMatcher": {
               "fileLocation": [
                   "relative",
                   "${workspaceRoot}"
               ],
               "pattern" : {
                    // Regular expression. 
                   // Example to match: helloWorld.c : 5:3 : Warning: Implicit declaration of 'prinft' function 
                   "regexp" : "^(. *) : (\\d +) : (\\d +) : \\s + (warning error) : \\s + (. *) $ " ,
                    "file" : 1 ,
                    "line" : 2 ,
                    "column" : 3 ,
                    "severity" : 4 ,
                    "message" : 5
               }
           }
       },

       // // Run Binary (Windows)
       {
           "label" : "execute" ,
            "command" : "cmd" ,
            "group" : "test" ,
            "args" : [
                "/C" ,
                "${workspaceRoot}/${fileBasenameNoExtension}.exe"
           ]
       }
   ]
}

I think it's because of the spacing on the desktop, but I don't know how to solve it ㅠ<

1) Is this a spacing issue on the desktop? If not, how do we solve it?

vscode

2022-09-20 14:40

2 Answers

If it is a Korean problem, especially a path problem, it can be solved by making sure that the Korean folder does not exist on the file location path.


2022-09-20 14:40

I solved it. First of all, you can rename the desktop to System Variations, but I don't recommend it because it can cause problems. As the person above said, I gave up... ㅠ 한글 You can put it in the path where there is no Korean and run it..


2022-09-20 14:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.