2020年7月6日 星期一

Redirecting standard input\output in Windows PowerShell

現象:在 Windows 10 上使用 Visual Studio Code 練習寫 C++ 程式時,VS Code 整合的 Terminal 為 Powershell 不支援原先在 cmd 視窗中可以使用的 '小於' 導向符號 (RedirectionNotSupported)。

在網路上查到的 Powershell 中重新導向 stdin 的命令寫法有二,如下:

  1. Get-Content a694.txt | .\a694.exe
  2. cat a694.txt | .\a694.exe
此二寫法等同在 cmd 視窗下達『.\a694.exe < a694.txt』指令。