Using the Console
In this chapter
- get familiar with command line operations
- display formatted text to the screen
- read input from the keyboard
- understand how character data is stored as a code, ASCII and Unicode
- convert characters to their numeric equivalent
Whilst using the console is becoming less and less common for most users it is an ideal environment for getting started with introductory programming. There are other advantages too for writing console applications, they're usually simpler, we do not need to get bogged down in issues of user interface design and we can focus on the algorithms. Getting familiar with the console or terminal (the terms are largely synonymous) is a good thing too if you're looking for more control over your computer environment and can be an essential skill for any aspiring programmer.
The system console only displays text and expects the user to enter text, numbers or other data via the keyboard. In Windows the console, or terminal or command prompt, can be accessed by entering the command cmd.exe
. To be pedantic, cmd.exe
is really a shell, a program that is running in the terminal. It processes commands and returns output. The shell contains commands that help us interact with the operating system (OS) and each OS will have its own selection shells we can use. Learning about the available commands on different systems is not our priority here but getting familiar with the available commands is useful e.g. on Windows here are some of the more common commands you can run:
Command | Action |
---|---|
dir |
Show contents of current directory |
cd <dir> |
change to new directory <dir> |
mkdir <dir> |
Create new directory <dir> |
mov <src> <dest> |
Move <src> to <dest> |
del <file> |
Delete <file> |
Find out more here. You can find similar tutorials for getting to know the Linux shells e.g. Bash.