![]() The main() function is the entry point of program execution. I will explain its meaning later.ĭefines the so-called main() function. This line shall be present in all our programs. The directive " #include " tells the preprocessor to include the " stdio.h" header file to support input/output operations. A preprocessor directive begins with a # sign, and is processed before compilation. The " #include" is called a preprocessor directive. End-of-line Comment: begins with // and lasts until the end of the current line (as in Lines 4, 6, 7, 8, and 9).It may span more than one lines (as in Lines 1-3). Multi-line Comment: begins with /* and ends with */.But they provide useful explanation and documentation to your readers (and to yourself three days later). Comments are NOT executable and are ignored by the compiler. UNIX/Linux/Mac (Bash shell) - Run "Hello" (./ denotes the current directory) Windows (CMD shell) - Run "Hello.exe" (.exe is optional) On Text Editor with GNU GCC compiler, issue these command from CMD Shell (Windows) or Terminal (UNIX/Linux/Mac):.On IDE (such as CodeBlocks), push the "Run" button.Step 3: Run the Executable Code: Execute (Run) the program. Where gcc is the name of GCC C compiler -o option specifies the output filename (" Hello.exe" for Windows or " Hello" for UNIX/Linux/Mac) " Hello.c" is the input source file. UNIX/Linux/Mac (Bash shell) - Build "Hello.c" into "Hello" Windows (CMD shell) - Build "Hello.c" into "Hello.exe" On Text editor with the GNU GCC compiler, start a CMD Shell (Windows) or Terminal (Mac, Linux) and issue these commands:.On IDE (such as CodeBlocks), push the "Build" button.Step 2: Build the Executable Code: Compile and Link (aka Build) the source code " Hello.c" into executable code (" Hello.exe" in Windows or " Hello" in UNIX/Linux/Mac). #include // Needed to perform IO operations * First C program that says Hello (Hello.c) You should choose a filename which reflects the purpose of the program. A C source file should be saved with a file extension of ". Step 1: Write the Source Code: Enter the following source codes using a programming text editor (such as NotePad++ for Windows or gEdit for UNIX/Linux/Mac) or an Interactive Development Environment (IDE) (such as CodeBlocks, Eclipse, NetBeans or MS Visual Studio - Read the respective "How-To" article on how to install and get started with these IDEs).ĭo not enter the line numbers (on the left panel), which were added to help in the explanation. Let's begin by writing our first C program that prints the message "Hello, world!" on the display console: Hello, world! Getting Started - Write your First Hello-world C Program
0 Comments
Leave a Reply. |