In this course, Dan Gookin reviews the steps required to use a programming language to create software. The programming language is used to create a source code file. A source code file is plain text, containing the programming language instructions. The source code file is compiled into object code, and the object code is linked with other object code files and C programming libraries to create a program. The program is tested as the final phase of the C language development cycle.
- [Instructor] I'm certain that you're eager to get started, but you also are smart enough to know that you have a lot to learn. So before you dash off and write that brilliant program, I recommend you understand an overview of the entire programming process. This process is similar for all programming languages, so pay attention. Programming is the art of writing software. Software controls hardware, which is the physical part of an electronic device, such as a computer, phone, microcontroller, or some other gizmo. To create software you use a programming language, such as C, that's your tool, the programming language.
The programming process works like this. You use a programming language to write a source code file. This is a plain text document containing programming language instructions. The instructions are compiled, which translates them into something called object code. The object code is linked with other files, programming libraries, and perhaps other object code files to build the final program. The final step is to test the results. This is the big picture. Everything starts with a source code file.
To create this file you use a text editor. Any text editor does the job, though some offer fancy features such as colored text and character matching, which helps greatly when you're starting out. This is the Codeblocks text editor. It uses colored text to highlight the source code. It also offers line numbers, and it lets you collapse and expand blocks of code to help you keep things organized. The contents of the text file are written in the programming language using the language's rules, syntax and formatting.
For a C language source code file, the file name ends with a .c filename extension. The source code is then compiled into object code. The program that creates the object code is called a compiler. The traditional name of the C language compiler is cc, which stands for C compiler. The compiler reads the source code file and generates an object code file. This file isn't a program, but rather contains shortcuts, or abbreviations called tokens.
Object code files have a .o filename extension, and they use the same filename as the original source code file. The next step is linking. Modern C compilers combine both the compiling and linking steps, though linking is really its own step. The linker takes the object code file and combines it with other object code files, and C language libraries. The libraries do the real work in the C language. They contain the actual routines, or functions, that control whatever device you're programming.
If all goes well, the result is a program file which you can test run to ensure that everything works. These steps comprise the programming cycle, or the process you go through to code a program in C, or any programming language. Edit, compile and link, which are really two steps, though they're often combined and called "build", and then test run. All of these tools, the editor, compiler, and linker, originated at the command prompt, or the terminal.
You can still find them there too. I do a lot of coding at the command prompt because it's quick and easy, plus I enjoy being a nerd. More commonly however, is to use an IDE, or Integrated Development Environment. An IDE combines the tools for editing, compiling, linking, and running. It also adds tools for debugging, creating complex programs, and other features. Beneath it all however, is the humble command line compiler and linker. And the process is the same.
Edit, compile and link, or build, and run. Although in practice you'll be doing a lot of repeating and reworking before you get things just right. That's the programming cycle.
- Recognize how to obtain a compiler and IDE.
- Determine the basics of C code.
- Identify how to add comments to the code.
- Break down how to work with escape sequences.
- Examine when is the best time to introduce variables.
- Recognize when the components of working with strings.
- Evaluate how to make calculations.