-
Notifications
You must be signed in to change notification settings - Fork 0
C Getting Started
The first thing you need to know how to do in C is to create the main function, which will be executed when you run your program.
You also (almost) always will want to include stdio.h at the top of your program (outside of your function), which will allow you to output to the console, and receive input from the console.
You can do this with
#include <stdio.h>Next, to create our main function, we can do:
int main() {
/*Your code goes here*/
return 0; /*We will use this, for now, to tell us that our program works, but this is not required*/
}Now, we want to make something happen when our program is ran, so, we will output to the console. We can use printf for this.
You should note that at the end of every line of code, you need to add a ; to tell C that it is the end of the line.
To output Hello World! to the console, we can do printf("Hello World!")
All together now:
#include <stdio.h>
int main() {
printf("Hello World!");
return 0; /*We will use this, for now, to tell us that our program works, but this is not required*/
}Output:
Hello World!
All content on Azetrico Developers is licensed under a Creative Commons Attribution 4.0 International License unless stated otherwise.
