Fireship · @fireship

C in 100 Seconds

Uploaded November 10, 2021 · Length 2:25

C in 100 Seconds

Summary

c programming language basics in 100 seconds, including syntax, variables, memory management, and compilation.

  • c programming language
  • c syntax
  • c variables
  • memory management in c
  • c compilation

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    C A statically typed procedural

  2. 0:02

    programming language famous for making

  3. 0:04

    the world go around it's the language

  4. 0:06

    behind many tools we take for granted

  5. 0:08

    like the windows Linux and Mac operating

  6. 0:10

    system kernels databases like MySQL

  7. 0:13

    interpreters for languages like python

  8. 0:15

    tools like vim and git and countless

  9. 0:17

    others it was created in 1972 by Dennis

  10. 0:20

    Richie at Bell Labs where it would be

  11. 0:22

    used to develop the Unix operating

  12. 0:24

    system it would go on to become the

  13. 0:25

    mother of all languages inspiring the

  14. 0:27

    syntax of C++ CP Java JavaScript Pearl

  15. 0:31

    and PHP just to name a few it compiles

  16. 0:34

    directly to machine code and requires

  17. 0:35

    minimal runtime support but is platform

  18. 0:38

    dependent meaning the executable is

  19. 0:39

    designed to run on a specific operating

  20. 0:42

    system it's a highlevel language

  21. 0:43

    designed for humans yet provides

  22. 0:45

    low-level control over memory and

  23. 0:47

    Hardware there's no garbage collector

  24. 0:49

    instead your code needs to manage its

  25. 0:50

    own memory when you create a variable

  26. 0:52

    it's assigned an address in memory you

  27. 0:54

    can store that address in another

  28. 0:56

    variable called a pointer when the

  29. 0:57

    variable is no longer needed you'll need

  30. 0:59

    to free it to avoid memory leaks to get

  31. 1:01

    started install a c compiler a popular

  32. 1:04

    choice is the g c compiler or GCC create

  33. 1:07

    a file ending in. C include any

  34. 1:09

    libraries you plan to use then add a

  35. 1:11

    main function to it this is where your

  36. 1:12

    program will start executing there's no

  37. 1:14

    function keyword and notice how it

  38. 1:16

    returns an integer type a return value

  39. 1:18

    of zero means success while a return

  40. 1:20

    value of one means failure there are

  41. 1:22

    only a few basic types in C create a

  42. 1:24

    variable by starting with a type

  43. 1:26

    followed by a name and value use print F

  44. 1:29

    to print the value to the standard

  45. 1:30

    output or put an Amper standand in front

  46. 1:32

    of it to reference its address in memory

  47. 1:34

    there's no string type but instead Char

  48. 1:36

    which represents a one by character

  49. 1:38

    stored as an integer a string can be

  50. 1:40

    created with an array of characters each

  51. 1:42

    letter will have its own memory address

  52. 1:44

    and be terminated by a null character

  53. 1:46

    another approach is to start with a

  54. 1:48

    pointer by adding a star character in

  55. 1:50

    front of the type then we can allocate

  56. 1:52

    four bytes to it now assign a character

  57. 1:54

    to each index ending with the null

  58. 1:56

    character to create a string when you no

  59. 1:58

    longer need that memory allocated to

  60. 1:59

    your program use free to release it back