Compile C Hello World Program

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/compile-c-hello-world-program/
PINTEREST
PINTEREST
INSTAGRAM

C Programming Tutorial Index

  1. Introduction To Programming
  2. C Setup Development Environment
  3. C Hello World and Compile First Application
  4. C Syntax and Basics
  5. C Variables
  6. C Numeric Variable Types (Integer, Long, Float)
  7. C String Variables
  8. C Constants and Define Processor
  9. C Operators
  10. C If Else and Switch Case Conditionals
  11. C While Loops
  12. C For Loops
  13. C Arrays
  14. C Functions
  15. C Structure
  16. C Union
  17. C File Operations (Open, Read, Write)
  18. C Pointers
  19. C Type Casting
  20. C Header Files and Include

Now we are here in start point. We will write a simple application which is generally a Hello World. This is very important because writing, compiling, running a C application is very important for beginners.

Hello World

Now our code is below. I have written this code very clear way line by line. This code provides basic structure of a C program.

  • #include <stdio.h> is a library which provides required functions for our program. Libraries provides functionalities required in applications. For example if we need some math functions like sin,cos etc. there is two way to solve this problem. One way is to implement these function by writing them scratch which is very tricky and time consuming job. Other way is using existing libraries those provides these as functions or other ways in a very efficient way.
  • int main() { … } is our programs entrance function. By default C applications starts running from main function. Here int is not important for us but we will look it future chapters.
  • /* I am C developer */ is not part of code it is called comment. Comments are not included in to program executable they are just resides in source code. Comments are very useful way to make our application readable and understandable.
  • printf("Hello, Poftut! \n"); is the actual code part here use use the function printf  and provide text which will be printed to the standard out put.
LEARN MORE  How To Compile Linux Kernel

Compile

Now our code is ready to compile and create an executable. Compiling will convert our source code to an executable. Executable means a file that can be run on the Operating System. We will use gcc. First we save our code to a file named hello.c . And now we can simple call gcc like below by providing our source code file.

Now an executable file name a.out is create by gcc. We can simple run this file like below.

Set Name Of Executable File

As we see above created executable file is named a.out . This is an ugly way. In big projects this will fail the compilation. We can set a name for newly created executable file with -o parameter of gcc.

C Programming Tutorial Index

  1. Introduction To Programming
  2. C Setup Development Environment
  3. C Hello World and Compile First Application
  4. C Syntax and Basics
  5. C Variables
  6. C Numeric Variable Types (Integer, Long, Float)
  7. C String Variables
  8. C Constants and Define Processor
  9. C Operators
  10. C If Else and Switch Case Conditionals
  11. C While Loops
  12. C For Loops
  13. C Arrays
  14. C Functions
  15. C Structure
  16. C Union
  17. C File Operations (Open, Read, Write)
  18. C Pointers
  19. C Type Casting
  20. C Header Files and Include
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/compile-c-hello-world-program/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)