2019/12/03

Linux Programming In C - A Simple Hello World

This is a quick summary of how to write and run a C program in Linux.

A Simple Hello World

1. Issue the command "sudo nano hello-world.c" to launch the nano editor;

2. Enter the code below in nano. Press Ctrl-X then press Y to save.

#include <stdio.h>

int main()
{
   printf("Hello, World! \n");
   return 0;
}

3. Issue the command "gcc hello-world.c -o myfirstcprogram" to compile;

4. Issue the command "./myfirstcprogram" to execute it.

Reference:

HOW TO WRITE AND RUN A C PROGRAM ON THE RASPBERRY PI
http://www.circuitbasics.com/how-to-write-and-run-a-c-program-on-the-raspberry-pi/

No comments:

Post a Comment