then what will be the output the output will be NUMBER_TOKEN this is cool using malloc we are able to allocate some amount of memory reserve some amount of memory but why do we reserve memory we reserve our allocate memory because we want to store some data there so we do not want to just randomly allocate some number of bytes so all that is correct to write a statement like this in practice we would not do so in practice we would first calculate how much amount of memory we need to store our data so let's say we want to store an integer just one integer so i need a memory block equal to the size of one integer so we typically use the function size off which returns us the size of a variable in bytes to figure out the size of the data type and then we typically multiply this particular value returned by size off by the number of units that we need so if we need just one integer if we need memory for just one integer and this is good if we need memory for NUMBER_TOKEN integers we would write something like this give me NUMBER_TOKEN into sizeof integer integer is a primitive data type sometimes you may know that i know that size of integer is NUMBER_TOKEN bytes so i can write something like NUMBER_TOKEN into NUMBER_TOKEN here but it's not a good practice to do so size of a variable depends upon the compiler and we would also be using malloc to allocate memory for complex data types so we must use malloc like this total number of bytes should be written as number of elements into size of one unit one unit of the data let's say we want to have space for three integers i have picked up three so that i have enough enough space to allocate memory in the figure that i'm showing here and let's say and this block of NUMBER_TOKEN bytes is allocated because size of integer is four bytes typically so this starting address would be NUMBER_TOKEN now how do we fill in data here if you see malloc returns a void pointer and void pointer as such cannot be dereferenced you cannot write a statement something like asterisk p is equal to NUMBER_TOKEN this is incorrect you cannot dereference a void pointer white pointer in fact is only used as a generic pointer type which is normally type casted into a pointer type of a particular data type and then it is used because malloc itself is a generic function to allocate some number of bytes in memory in heap it does not care where whether you are allocating this memory to store character or to store integer or to store any other data type it simply returns a void pointer to the starting address to be able to use this block of memory we first need to typecast this void pointer into a pointer of some data type so here we will write something like in star p instead of picking up a void pointer we pick up a pointer to integer because we want to operate with integers so to d reference we need an integer pointer type so we do the type casting here of the void pointer and now this statement is valid if we want to assign some value to the second element second integer in this list then we will do something like we will de-difference the address p plus one let's say we write the value four here and if we want to access the third integer then we will write something like this let's say the value of six here by asking for a memory block for three integers we are basically creating an array of integers with three elements we could
NO_SEGMENT_TOKEN