Skip to content

Instantly share code, notes, and snippets.

@wc2184
Last active November 21, 2025 00:07
Show Gist options
  • Select an option

  • Save wc2184/fd829d0d2e49eb044d92a41b4d964adf to your computer and use it in GitHub Desktop.

Select an option

Save wc2184/fd829d0d2e49eb044d92a41b4d964adf to your computer and use it in GitHub Desktop.
Striver Method of C++ input output file

VSCode C/C++ File Input + Output (Code Runner) Three Way View from this video

0. Download Code Runner extension for VSCode

0.5 Open Settings in VSCode (Cmd + , ), go to Code-runner: Executor Map, then open settings.json

1. Add these two lines in settings.json of the .vscode/ folder in the directory of your .cpp file.

"c":   "cd $dir && gcc $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt < input.txt > output.txt",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt < input.txt > output.txt"

2. Place files

input.txt ← program reads from this
output.txt ← program writes to this (auto-created)

Both go in the same folder as your .c/.cpp file.

3. Run / Stop

Run code (while focused on the .cpp file):
Ctrl + Option + N

Terminate code:
Ctrl + Option + M

4. After running

Open output.txt to see all program output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment