C How To Program 8e Before You Begin
C How To Program 8e Before You Begin
Software
Download and install a compiler for your platform.
To compile a C program:
1. Open Visual Studio.
2. Select File > New > Project…
3. In the left side of the New Project dialog, expand Templates, then select Visual C++.
4. In the center of the dialog, select Win32 Console Application.
5. At the bottom of the dialog, specify a name and location for your project, then click OK
In the Win32 Application Wizard dialog:
1. Click Next>
2. Uncheck both Precompiled header and Security Development Lifecycle (SDL) checks
3. Check Empty Project
4. Click Finish.
Next, add a source code file to the Source Files folder in the Solution Explorer at the right side of Visual
Studio—if this window is not showing, select View > Solution Explorer.
• If you want to run an existing program from our examples, you can simply drag its files from
Windows Explorer (Windows 7) or File Explorer (Windows 8 and 10) onto the Source Files folder
in the Solution Explorer. Once you’ve done this, you can type Ctrl + F5 to compile and run the
program.
• If you want to create a program from scratch—which I recommend even for our programs when
learning—right click the Source Files folder in the Solution Explorer then select Add > New
Item…. In the dialog, select C++ file, BUT name the file with the extension “.c” not “.cpp”—this is
how Visual Studio knows to compile the program as C rather than C++.
Compiling/Running Using GNU C++ on Linux
The prompt in the shell on our system uses the tilde (~) character to represent the home directory, and
each prompt ends with the dollar sign ($) character. The prompt will vary among Linux systems. We
assume here that you’ve already created or already have a .c file (such as one of our examples) that’s
ready to be compiled.