First Program

First program
hello.c
#include <stdio.h>
int main(void)
{
printf("To C, or not to C: that is the question. \n");
return 0;
}int: standard return type ➡️void(return type not accepted by all the architectures)(void): explicit parameter (best-practice) ➡️()implicit parameter (alternative)
hello.c (command line version)
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("To C, or not to C: that is the question. \n");
return 0;
}argc: number of strings specified in command lineargv: array of strings specifies in command line (separated by spaces)
Compilation
gcc hello.c -o helloExecution
./helloIf you create the command line version of the code, you can specify several arguments. For example:
./hello arg1 arg2 ag3argc➡️4argv➡️["./hello", "arg1", "arg2", "arg3"]
Comments
// Single-line comment
/* Multi-line
comment */Last updated