How to Create, Compile & Run a C program
1. Create a C file
You can use any ordinary text editor to create a C file. In windows, you can find Notepad as a default program. If you are using ubuntu operating system, you can use gedit or vi editors.
When you are saving the file, the file extension should be .c
Eg: helloworld.c
You should write a program where it must be according to the C syntax.
2. Compile a C file
There are many C compilers out there such as default Sun Compiler (cc), GNU C compiler (gcc) and Borland (bcc) compiler.
All these compilers work in the same way and share many common commands.
Command to compile:
GNU C compiler – gcc helloworld.c
Borland compiler – bcc helloworld.c
Here, helloworld is the file name.
Note: After compilation, you will a.out file by default. If you want to rename the output, give the command like below.
cc helloworld.c -o hello
In this case, the output file will get renamed to hello.
3. Run a C file
If you didn’t rename the output file, you can simply type ./a.out
If you have renamed, you should run the program as ./hello
Thank you guys for reading, in the next post I’ll show how to do the above steps practically.
Till that stay tuned with BB Tech ☺
0 comments:
Post a Comment