Dynamic Memory Allocation

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

This video alone could replace a couple of hours of lectures at every university about this same topic.

Papayalexius
Автор

Watch out because an int doesn't have to be 4 bytes! It has to be at least 4 bytes, but it could be bigger. Always use sizeof(int). Same for float by the way.
EDIT: also, the preferrable syntax for a pointer is with a space before the * but not after it. So int *a instead of int* a. Both will work of course, but the philosophy of C is that *a is an int, not that a is an int*. Also, when you say int foo(), that means that when you type foo(), it's an int. This does imply that foo is a function that returns an int, but this is not explicit.

fghsgh
Автор

Doug you made my day man. Especially last part was superb.

aylin_ve_babasi
Автор

At 12:19 forward a can never point to the address of pointer b. a = &b would result in a compiler error as follows:
error: incompatible pointer types assigning to 'int *' from 'int **'

For this example irrelevant but keep this in mind, if you want to address a pointer to an in using another pointer you have to use int **a to resolve compiler error for a = &b

codetofail
Автор

This was a great video. The ending was not only a great display of malloc, but also a great visual display to wrap in pointers as well

HappehLemons
Автор

The browser he wouldn't name is definitely Chrome no doubt.

hankchanocd
Автор

This makes so much more sense, Thank you!

safb
Автор

superbly explained !! No other video helped me catch the logic

damrukeshdaliparti
Автор

Awesome video, made my understanding of pointers and dynamic memory allocation better.

exismys
Автор

I think it would good to point out that &b lives on the stack, and b (the adress it points to) lives on the heap.

pyb.
Автор

This Video is very helpeful, thank you

vitordasilva
Автор

finally I understood malloc! thank you!

nygmankusainov
Автор

If i later(after a=b) changed where `b` points to, would that also change where `a` points to?

berkk
Автор

Wow! You really explain what is going on.

jimmybodine
Автор

I don't understand this (6:22):
float stack_array[x]
How can a stack array reserve memory of a size that's entered only at runtime? Is a dynamic allocation really possible on the stack? And if so: What's point of using malloc and heap?

trodelbardeuwe
Автор

f*ck! why my prof cannot explain it to me this way. Love cs50

dadogogosh
Автор

dude, wonderful explanation, it helped me a lot. But ther is NOT a compile-time memory allocation.
All type of variables are allocated during runtime. ALL!

giangi
Автор

Why the profile picture is a cat? It's irrelevant but cute though.

diverseprogrammer
Автор

When do you use pointers? Like what is the point of using them.

chrisgentolia
Автор

Does shutting down your pc or system, free the dynamic allocated memory since it was created on RAM.?

pastafarian