I learned some more things about C:
- To print text to screen we need a function that does this. The function comes packaged with C in a library called the “Standard Input/Output library”. (stdio.h)
- The way you include a file with C is by writing: #include<myfile.h>
- Some programming languages require you to create a function to write a program. The function that does this on C is the function “main”.
- In C you call a function by putting the function name along with any arguments within parenthesis. At the end you put a semi-colon.
- The function to print something on C is printf(“Hello”);
- On C u need to specify when to return back control to operating system when the program finishes. To do this you use “return” . For example return 0;
e.g example_function (“Text to print”);
The syntax for main is:
int main (void) { … code goes here … }
- So it seems the “int” states the kind of output that is going to be produced. In this case an integer. When writing a function we need to state the kind of output we can expect from the function.
- Lastly, “main” means that we are not passing any variable to the function.