C in 100 Seconds

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

This is a pretty bad guide.

"You can store that [memory] address in another variable called a pointer. When the variable is no longer needed, you'll need to free it to avoid a memory leak"

This is very confused. The function free is a standard library function which frees a block of memory allocated via malloc/calloc/realloc, etc. The allocation functions give you a pointer, and free takes a pointer, but that's where the connection ends. There's nothing whatsoever in the notion of a pointer itself that requires you to call free to avoid a memory leak. You can of course have multiple pointers to the same memory; for instance, you might use a pointer to iterate over elements (and you wouldn't want to call free on the pointer when you were finished with the iterator!) which could be allocated on the heap or on the stack.

It's also quite amusing that the author's example compilation causes a seg-fault when run.

👍︎︎ 12 👤︎︎ u/Orakar 📅︎︎ Nov 10 2021 🗫︎ replies

Note: I am not the author of this video.

👍︎︎ 6 👤︎︎ u/Iuse_arch_btw 📅︎︎ Nov 10 2021 🗫︎ replies
Captions
c a statically typed procedural programming language famous for making the world go around it's the language behind many tools we take for granted like the windows linux and mac operating system kernels databases like mysql interpreters for languages like python tools like vim and git and countless others it was created in 1972 by dennis ritchie at bell labs where it would be used to develop the unix operating system it would go on to become the mother of all languages inspiring the syntax of c plus c sharp java javascript perl and php just to name a few it compiles directly to machine code and requires minimal runtime support but is platform dependent meaning the executable is designed to run on a specific operating system it's a high high-level language designed for humans yet provides low-level control over memory and hardware there's no garbage collector instead your code needs to manage its own memory when you create a variable it's assigned an address in memory you can store that address in another variable called a pointer when the variable is no longer needed you'll need to free it to avoid memory leaks to get started install ac compiler a popular choice is the gnu c compiler or gcc create a file ending in dot c include any libraries you plan to use then add a main function to it this is where your program will start executing there's no function keyword and notice how it returns an integer type a return value of 0 means success while a return value of 1 means failure there are only a few basic types in c create a variable by starting with a type followed by a name and value use printf to print the value to the standard output or put an ampersand in front of it to reference its address in memory there's no string type but instead char which represents a one byte character stored as an integer a string can be created with an array of characters each letter will have its own memory address and be terminated by a null character another approach is to start with a pointer by adding a star character in front of the type then we can allocate 4 bytes to it now assign a character to each index ending with the null character to create a string when you no longer need that memory allocated to your program use free to release it back to the computer's ram the language is procedural and does not support object oriented features although you can create your own complex data types using structs now compile your code to machine instructions for your operating system using the c compiler this has been the c programming language in 100 seconds hit the like button and subscribe if you want to see more short videos like this thanks for watching and i will see you in the next one
Info
Channel: Fireship
Views: 396,571
Rating: 4.9661527 out of 5
Keywords: webdev, app development, lesson, tutorial
Id: U3aXWizDbQ4
Channel Id: undefined
Length: 2min 25sec (145 seconds)
Published: Wed Nov 10 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.