C Programming Tutorial 62, The Stack

Comments

Samuel Becker says:

You’re a liar, this video isn’t sixty seconds long!

Shockszzbyyous says:

in my mind memory is a huge stack of addresses in which to store data, not like a grid 🙂

valdezapg says:

Very good video, thanks

dj muaaz728 says:

not much understandable …..
pakistanis and Indians are much better to explain this ……

Gran Cero says:

the visualization drawing is a really good way to teach, but how can u be so sure that the variables you create will pile up in the order that you initial them to be?

MBlu3 says:

let’s say you declare a string array, without initializing it ( it takes values from the user).
since the size of this array will depend on the user input, how will the program know how much space to keep for it?

what happens in that case?

Divyam Patro says:

Hey adam I’m not able to print the string when i pass the address of Bob as &s1+2…can u plz tell why not?

Mohamed Labouardy says:

so the short will be cast to 4 byte before pushed in the stack

simran singh says:

“bottom of stack” :’D 😛

Dan says:

3:03
“memory is more like a grid”
Well, no, more like address locations stacked on top of each other, as you were drawing it.

iTzAdam5X says:

It’s actually an image that I found on google.

iTzAdam5X says:

When/If you get into an assembly language, this sort of thing is very useful. Also, I think it’s important to have a gist of what’s going on behind the code you write.

Stenfeldo says:

beautiful! thanks!!!!

iTzAdam5X says:

Often compilers will rearrange variables for speed and ease of access.

h tt p :// stackoverflow . com/questions/238441/can-a-c-compiler-rearrange-stack-variables

Mohamed Labouardy says:

we can only push a 4 byte in the stack !!

Supachai Abusali says:

thnx a lot.. but can u make more videos on dynamic data structures in C?

iTzAdam5X says:

I’m not really sure what you’re asking. There is no way to make an array without giving it a size. You could create a pointer, like this:

char *myArray;

Then you could start assigning values to it like this:

myArray[0] = 6;

But that doesn’t really make any sense. The address stored in that pointer will be just some random value that happened to be on the stack. That assignment will most likely result in a segmentation fault because it will be accessing a random part of memory.

Winston Mcgee says:

I was expecting you to explain the stack as a data structure, and implement it in C, not some fucking memory management stuff what a waste of time

李韦淦 says:

是不是在C语言中, 对于用户输入的未指定长度的字符串,只能定义一个足够 大的字符数组来解决?有没有方便点的方法?

Corrado I says:

Hi Adam.
Thank you for your tutorials.
I have a question, I would like to print address and value of an int:
int i = 6;
str[4] = “test”;
printf(“%i = %in”, &str1 + 1,  &str1 + 1);

Thank you,

Corrado

thewhisperinyourears says:

whats the fundamentals of this? what is stack knowledge use for?

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!