Running Your Programs in a Shell

For non-trivial programs, it is much more convenient to run them directly from an interactive shell (command line) than via Console plugin of VS Code, especially if input is to be taken from a file, or output collected into a file. here are the commands you need. As using interactive shell (i.e., cmd in Windows) is required in this subject, you should familiarise yourself with these commands.

Operation On a PC you.. On a Mac you…
Start a window to execute a shell Go to “Start > Run”, type cmd, and then click ok. You can also pin this command to your start menu, or make a desktop shortcut. Find “Applications”, then “Utilities”, then double click “Terminal” (might also be available directly from your dock, and if it isn’t you can put it there).
See where you are The current directory is part of the prompt string pwd
Generate a directory listing dir ls
Change to a subdirectory cd directory
Note that typing tab will do filename completion, and directory .. is the parent.
cd directory
Note that typing tab may do filename completion, and directory .. is the parent.
Move up one directory cd .. cd ..
Delete a file or directory del filename
del 
 directoryname
rmdir directoryname
rm filename
rmdir 
directoryname
Execute a program project orproject.exe ./project
View a text file type filename more filename

On both systems, use of “<” does input file redirection, and “>” does output file redirection.

Finally, note that on a PC, if you make a desktop shortcut to cmd (the original is probably located in C:\Windows\System32) , you can then right-click the shortcut it to select Properties, and then add in a directory that it will always start executing the shell in. Saves a bit of cd’ing. The Mac provides even better shortcuts for getting to particular directories.