Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C Programming Tutorial #1
I will start off by saying that I am not perfect, What I write here may be wrong. We are all learning so be sure to update me when I say something wrong in the comments below. Thank you, now into the nerdy stuff.

Alot of the information that I will be giving you will be from Bucky's C Programming Tutorial on YouTube. So feel free to watch them to get more information on the topic.
0: Installing Code::Blocks and Setting Up
There is countless tutorials out there for installing this so just look around.

Once installed, goto Create New Project>Console Application>Skip Next Time>C>Name File>Pick Dir>Click Sources>Click Main.c!!

Code should apear that looks like the code I have showed below. If not, feel free to copy and paste the code below to follow along with the rest of the tutorial.
1: Printing Text!
int main()
       //This is a comment
       printf("Hello World!");
       return 0;
I dont expect you to know a single thing that I just typed, but hopefully after this tutorial you will.
I will go through everything I just typed line by line so you have an understanding of whats going on.

Line 1: #include
You need this in your program unless:
"If all a C program is doing is modifying some memory locations, and isn't doing I/O, then stdio.h isn't needed."

Line 2: int main()
int main() is for returning a interger value but you can also use "void main()" and that will return nothing.
When useing "void whatever()" you do not have to return 0;

Line 3-7: {   }
"Main()" is a function, so you need to be able to tell it when to start and stop. And this is where these curly braces come in handy, with these bad boys. You can tell the function start with "{", and tell it to stop with "}". And inbetween the braces you can put code inside as you see in the example.

Line 4: //Comment is a comment
This line is pretty easy to understand, but for those who done know. This is a comment(lel). This is a note for the programmer or programmers reading the code. You can have millions of comments but they will not change how the program works. To write a comment you have to type "//" then the text you want to remind yourself with.
//I love TrynCatchMe!
Comments only work on the line you wrote the "//" on. I will get into multiline comments, but that is for a later tutorial.

Line 5: printf("Hello World!");
printf, Your best friend. This is the most used line you will ever use when starting off making gay(no hate towards homosexuals) little games and such. This will print text into the console. To use this, you will have to type "printf("(TEXT HERE)");", where it says text here, you type what you want to say(obv), for a test just type "TrynSmash is kool!".
printf("TrynSmash is kool");
You need to end EVERY printf off with a ;
The rule above applys to almost everything I can think of so dont forget to add a ";" at the end of you printf

Line 6: return 0;
Don't have much to say on this line, just to put it at the end of any function that has "int FUNCTIONHERE()"
This is not needed for void FUNCTIONHERE() as I stated before...

Running The Program!:
To test the sexy project that you have created you have to press the image of the Gear and Green Arrow above your code. A console will appear with the sexy program you made.
If nothing happens you will see text under your code that will tell you the error.
Be sure to read over that cause it will tell you every thing wrong with your code!!!

I am going to make more whenever I feel like so dont expect 20 a day!

Ποιος το διάβασε:
1 User(s) read this thread:
Gaara (07-02-2016, 02:46 AM)


Users browsing this thread:
1 Guest(s)

This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.