To embark on using C, you’ll require:
– A text editor, such as Notepad, for writing C code.
– A compiler, like GCC, to translate the C code into machine-readable language.
Numerous options exist for both text editors and compilers. In this tutorial, we’ll utilize an Integrated Development Environment (IDE) (refer to the section below).
An Integrated Development Environment (IDE) serves the dual purpose of editing and compiling code.
Common IDEs like Code::Blocks, Eclipse, and Visual Studio are freely available and proficient in both editing and debugging C code.
Please note that while web-based IDEs can function, their capabilities are restricted.
For this tutorial, we’ll opt for Code::Blocks, a recommended starting point.
You can obtain the latest version of Code::Blocks from http://www.codeblocks.org/. Simply download the mingw-setup.exe file, which installs the text editor along with a compiler.
To initiate our first C file, launch Code::Blocks and navigate to File > New > Empty File.
Enter the provided C code below and save the file as myfirstprogram.c (File > Save File as):
#include <stdio.h>
int main() { |
If the code appears complex at this stage, don’t worry. We’ll delve into its intricacies in subsequent chapters. For now, concentrate on executing the code.
In Code::Blocks, the interface should resemble the following:
Next, navigate to Build > Build and Run to execute the program. The outcome should resemble something like this:
Hello World! Process returned 0 (0x0) execution time : 0.011 s Press any key to continue. |
Well done! You’ve successfully authored and executed your inaugural C program.
When studying C on code7School.com, leverage our “Try it Yourself” tool, showcasing both the code and its corresponding output.
This feature enhances comprehension of each aspect as you progress.
Code:
#include <stdio.h> int main() { printf(“Hello World!”); return 0; } |
Result:
Hello World! |