C Programming Tutorial – 3 – How Computer Programs Work



alright guys welcome back to another video tutorial and in this video before we actually start typing a bunch of crap on the screen we need to understand exactly how a computer program works so let me explain that right now every computer program is made up of these things called functions now the job of the function is just to tell your computer to do something so again a computer program is pretty much built of several of these functions usually this one only has one but let me go ahead and give you guys an example say that we want to make a program that will watch a YouTube video for us so the first function would be take your mouse and move it to this Google Chrome icon second function click third function click on videos fourth function play a video or something so again as you can see a computer program is made up of these pieces called functions now right here this one right here is actually a very basic function that's necessary for all C programs and I'll tell you guys about the different pieces of this right now just so we actually have an idea of what we're looking at so pretty much whenever you've run a program the computer is automatically going to look for a function called main so you need to have this function no matter what now your function starts and stops at this curly brackets that's why that's how it knows what code goes in your function so every line in between here is part of this main function so let's take a look at these lines right now so every single line is just a piece of instruction to tell your function what to do and also you probably want to take note of every line ends with a semicolon that's how it knows to end this piece of instruction and go to the next line so the first thing our program does whenever it starts is run main and then it says ok well what's in main what do you want me to do well the first thing is print text out on the screen and I'll tell you guys more about how this works later on but this is pretty much the line that prints text out on the screen and that's why whenever you run program we see it says hello world so that's what that line does right here now it has one other line and says return zero and for now um that's just kind of like the background of what's going on why um how can I explain this how your program and functions work they need to return something and it just says okay if you return zero it means this function ran correctly sometimes if you have a return one or something that means an error but basically if you return zero to main it means that your program is running a-okay so that's what that line does talk about more more on that later now the only other pieces we don't understand yet are these lines right here these include lines are basically saying this see whenever you have whenever you have a C program the C language comes with a bunch of built-in functions by default so this function right here um allows you to print crap out on the screen like this however we need to tell our program to include those files so we can get those basic on default functions so right here we're basically saying include a bunch of built-in um crap that we can use in a program this is our main function the very first um piece that runs and the only important piece of instruction right now is printing textile on the screen so that's basically what's going on behind the all behind the scenes and another thing I want to mention is this blank lines and indents and whitespace it doesn't matter to your computer program it's just for making your code more readable so if you want to put enter a bunch of times if you think that's more readable if you want to press tab and put this way over there it doesn't matter it's just for clean that up a little bit it's just for um the person the developer whatever is the easiest to see so again whitespace blank lines indents don't really matter arm again every single computer program is made up of func law cantock functions which pretty much do something and every single function is made up of lines of instruction to tell that function exactly what to do so now that we understand how a very basic computer program works in the next tutorial we're actually going to begin our hands dirty and starting to actually code but for now then guys for watching don't forget to subscribe it and I'll see you guys in the next video

26 thoughts on “C Programming Tutorial – 3 – How Computer Programs Work

  1. Hey bucky, Im starting to learn and just realized your forum is down, please dont take down these videos!

  2. OUCH! Having problems:
    Created a project, edited main.c and added source code, compiled/ran successfully, saved everything. closed Codeblock. PROBLEM, when I try to reopen the project, its does now recognize any project was created. What am I missing???
    Is there some kind of special place to add projects and workspaces??
    Or a setting to point to a project/workspace directory???

    ….. help …….

  3. u are an awesome teacher but if the size of font was increased by holding ctrl +scrolling up then it would be more awesome. ! i love the way you teach SIR ! <3

  4. Hi,

    Please help me to understand this program.
    This program is to find the position of a substring from a string.

    #include<stdio.h>

    int stripos(char* haystack, char* needle, int offset );

    void main()
    {
    char a1[200], a2[20];
    int iPostn = 0;
    printf("ENTER THE HAYSTACK STRING:n");
    gets(a1);
    printf("nENTER THE STRING – TO BE SEARCHEDn");
    gets(a2);
    iPostn = stripos(&a1[0], &a2[0], iPostn);

    if(iPostn > 0)
    printf("nSTRING STARTS AT THE POSITION: %dn", iPostn);

    else
    printf("nSTRING NOT FOUND: %dn", iPostn);

    getch();
    }

    int stripos(char* haystack, char* needle, int offset )
    {
    char ch, *needle1;
    int pos = 0, temp;

    if(haystack != '' && needle != '')
    {
    while(*haystack != '')
    {
    needle1 = needle;
    pos++;
    temp = 0;
    if((*haystack == *needle1) || (*haystack == *needle1 – 32)
    || (*haystack == *needle1 + 32))
    {
    offset = pos;
    needle1++;
    haystack++;
    while(*needle1 != '')
    {
    if((*haystack == *needle1) || (*haystack ==
    *needle1 – 32) || (*haystack == *needle1 + 32))
    {
    haystack++;
    needle1++;
    pos++;
    }
    else
    {
    temp = 1;
    offset = -1;
    break;
    }
    }
    }
    if(offset > 0)
    {
    return offset;
    }

    if(temp != 1)
    haystack++;
    }
    }
    return offset;
    }

    Questions:
    1. What is stripos ? I can only find strpos (string position) online but not stripos.
    2. What is iPostn ?
    3. Or please explain each line of the code.

    Thank you!

  5. Hey @thenewboston , I'm in a coding bootcamp and were learning C and we can't use the printf function. Which really really sucks.

  6. Bucky, please keep up the good work, you surely best one, so easy to listen and not get distracted. Honestly we all know that for beginners coding is boring, but you make it interesting and that's just amazing. Great job man!!!!

  7. Your videos are great mr bucky by you only i know not only codes of C but also java script too……thank you…

Leave a Reply

Your email address will not be published. Required fields are marked *