|
CS256 - Principles of Structured Design
Fall 2021
|
Displaying ./code/cs256su21code/first/helloDet.c
/*
this is a multiline comment
comments are used to help other people
understand your code
the compiler will ignore everything in here
*/
//this is also a comment, but for single lines, the compiler ignores this line
#include <stdio.h>
/*
#include is a preprocessor command that includes a header file(in this case
stdio.h) from the C library before compiling a C program, we needed to have
stdio.h in order to use printf
*/
//below is the "main" function, the very first function every C program calls
//"int" in this context means that the value returned by main will be an integer
int main() {
//everything inside these curly braces belongs to the main function
printf("Hello, World!\n");
//this function prints "Hello, World! and a new line onto the screen
return 0; //return ends the program and returns 0
//in this context, if it returns 0, the program worked!
}
/*
After finishing this program, you will then compile and then run the program
To compile this file, run the following command on the terminal: gcc hello.c
that will produce an executable named a.out, to run that type ./a.out to run the
program.
By default, the executables will be named a.out, to give your executable a name,
you will use the following format: gcc -o <name of executable> <source file>
So if you wanted to name the executable produced by compiling this source code
"hello" you would simply type "gcc -o hello hello.c" and that will produce an
executable named "hello"
*/
|