Skip to main content

How to compile C program in Linux

Although it is super easy to print "Hello World!" in c program, you might wondering if you've switched to linux first time.
Here is the step by step process to compile and run a c program in linux.

1. Open terminal: (CTRL+ALT+T)

Terminal in Ubuntu 14.04 LTS

2. Change directory to desired location: cd DIRECTORY-NAME


3. Open your file in any text editor: Here I am using vim editor.


4. Vim will look something like this


5. Press "i" for go to insert mode


6. Type a "C" program


7. Press "escape" button then ":wq": Here escape key is used for go to command mode, :w for save, and q for quit. For more about vim commands you can visit here.


8. Now its time to compile the program with GNU compiler: Type "gcc" followed by C program you just typed. Hit enter. If there would by any error in your program it will be displayed. Go back to step 3 and fix them.


9. If a new line displayed without any message then it means program has been compiled successfully.


10. Good news, now its time to run your successfully compiled C program: Press "./a.out" and hit (or politely press) enter button.


11. Congratulations, You've just learned to compile and learn C program in linux.


Now you know how to compile and run a c program in linux.
Share if you feel others who are still programming with windows should also know this.

Comments

Popular posts from this blog

Some tools to make life easier

  O ver time, I’ve discovered that the right tools quietly remove friction from everyday work. From managing documents and media to backups, notes, and creative tasks, these applications save time and mental energy. Most are free or open-source, run locally, and respect user control—making them reliable companions for daily digital life. I. Productivity, Notes & Knowledge Management OneNote – Helps organize notes in a structured way using notebooks and sections, making it easier to revisit ideas even after long gaps. Samsung Notes – Works smoothly on Samsung devices and is especially useful for handwritten notes and quick ideas with the S-Pen. Joplin – Stores notes locally in Markdown format, giving full control over data without forcing cloud dependence. Logseq – Encourages thinking in linked ideas rather than isolated notes, which is useful for long-term learning and journaling. Xournal++ – Makes it easy to annotate PDFs and take handwritten notes, especial...

16 security tips for web developers

Web Security 1. Keep softwares up to date Many developers prefer to use old version of software because they are more familiar with that version. This may cause security breach. So, it is recommended to always stay updated with latest version. 2. Prevent SQL Injection SQL Injection is one of the most used attack to harm website. SQL Injection can be prevented by using prepared statement or using PDO (PHP Data Object). In prepared sql statement  a placeholder is used instead of mixing user inserted data in sql statement. 3. Prevent XSS Attack XSS (Cross-Site Scripting) is use to insert malicious javascript  code to a web page which can be use to steal cookies or other informations from browser. To prevent this type of attack clean user input before displaying it to webpage. 4. Double form validation Form validation should be done on both client side and server side. Client side validation is done with javascript which user can manually disable in h...

Reality of private engineering colleges in India

B eing an engineer is not only one of the most precious profession in India but it is also one of the most precious profession all over the world. Almost every children of this country wants to be either a doctor or an engineer. But the number of government engineering colleges are very few. More than a million student appears every year in the national level pre-engineering entrance exam. Number of seats in government colleges are approx 30k. So what about the remaining more than 970k students?? Here is the scope for private engineering colleges grab the opportunity.  They do whatever they can do to attract the students in their college. Many of them pretends that they are the best. Some says they are best in north India, some says the same thing about other direction. They use every medium of the advertisement. Some college takes their own entrance exam to get admission in their college, but this is nothing but only a show off. Time of admission: Students have to pay ...