formulahendry / formulahendry/vscode-code-runner
[Bug] code runner "Run in Terminal" with bad naming C++ file couldn't output right results
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 351
- PR merge metrics
- No merged PRs in 30d
Description
- VS Code Version: 1.91.1
- OS Version: Windows 11, 22631
- Code Runner Version: 0.12.2
**Describe the bug**
When code runner setting "Run in Terminal" set to True, bad naming C++ files (4.2.3.instr2.cpp for example) couldn't output correct results in terminal.
**To Reproduce**
Steps to reproduce the behavior:
1. Set "Run in Terminal" of code-runner to "True"
2. Create a C++ file with bad naming, for example "4.2.3.instr2.cpp"
3. Edit the C++ file, with input and output using `cout` and `cin`, for example:
```c++
// instr2.cpp -- reading more than one word with getline
#include
int main()
{
using namespace std;
const int ArSize = 20;
char name[ArSize];
char dessert[ArSize];
cout << "Enter your name:\n";
cin.getline(name, ArSize);
cout << "Enter your favorite dessert:\n";
cin.getline(dessert, ArSize);
cout << "I have some delicious " << dessert;
cout << " for you, " << name << ".\n";
return 0;
}
```
4. Run code with Ctrl+Alt+N
**Actual behavior**
The terminal outputs:
```powershell
PS G:\OneDrive\Obsidian\06-Coding\C++\cppPrimerPlus\chapter.4.compoTypes\4.3.stringClass> cd "g:\OneDrive\Obsidian\06-Coding\C++\cppPrimerPlus\chapter.4.compoTypes\4.2.strings\" ; if ($?) { g++ 4.2.3.instr2.cpp -o 4.2.3.instr2 } ; if ($?) { .\4.2.3.instr2 }
PS G:\OneDrive\Obsidian\06-Coding\C++\cppPrimerPlus\chapter.4.compoTypes\4.2.strings>
```
**Expected behavior**
```powershell
PS G:\OneDrive\Obsidian\06-Coding\C++\cppPrimerPlus\chapter.4.compoTypes\4.3.stringClass> cd "g:\OneDrive\Obsidian\06-Coding\C++\cppPrimerPlus\chapter.4.compoTypes\4.2.strings\" ; if ($?) { g++ 4.2.3.instr2.cpp -o 4.2.3.instr2 } ; if ($?) { .\4.2.3.instr2 }
Enter your name:
```
**Screenshots**

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.