2

I am getting error while running the C++ code in Visual Studio Code, I am not able to run any code in my editor, here there is the image of the error I had search many time about this but not get anything. I tried to use '|' in place of '&&' but still there is no improvement. My VS Code is up to date. would anyone like to share some fix for this. It seems that there is error in the '#include <bits/stdc++.h>' file as it says that there is error in line 1 and char 46, char 51 etc ...

this is the image of error

Any information regarding this will be appreciated, thank you for your time ...

Jarod42
  • 203,559
  • 14
  • 181
  • 302
Naimish
  • 29
  • 2
  • 5
  • 2
    [Why should I not #include ?](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h) – Nate Eldredge Mar 02 '21 at 04:30
  • I think you need to upgrade your version of powershell. I have the same error if I type `dir && dir` in PS 5.1 but 7.1.1 handles it fine. – drescherjm Mar 02 '21 at 04:36
  • 6
    This doesn't really have anything to do with C++, it's trying to run two commands in powershell with `&&` between. – chris Mar 02 '21 at 04:37
  • Related: [https://github.com/PowerShell/PowerShell/releases/tag/v7.1.2](https://github.com/PowerShell/PowerShell/releases/tag/v7.1.2) – drescherjm Mar 02 '21 at 04:43
  • Also: [https://learn.microsoft.com/en-us/powershell/scripting/install/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.1](https://learn.microsoft.com/en-us/powershell/scripting/install/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.1) – drescherjm Mar 02 '21 at 04:45
  • 2
    `&&` is not the way to execute multiple command in PowerShell, but `;` – JPBlanc Mar 02 '21 at 04:48
  • 1
    PLEASE, do not post images of code/errors/data. why? lookee ... Why not upload images of code/errors when asking a question? - Meta Stack Overflow — https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question – Lee_Dailey Mar 02 '21 at 09:09

2 Answers2

6

&& is not the way to execute multiple command in PowerShell, replace it by ;

JPBlanc
  • 70,406
  • 17
  • 130
  • 175
  • 3
    Beginning with PowerShell 7 you can use `&&` as Pipeline Chain Operator: https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-70?view=powershell-7.1#pipeline-chain-operators – swbbl Mar 02 '21 at 05:27
  • 2
    the OP just has very limited knowledge of powershell and C++ so I don't believe they install powershell 7 which isn't included by default themselves – phuclv Mar 02 '21 at 06:54
0

"&&" may not be distinguished by "AND" by the compiler. You should use ";" instead of it.