Additional points 1.null pointer is a pointer which points to the memory.where that memory is allocated to OS. We can't assign a memory to already reserved memory for OS. So why it's called null pointer 2.The size of pointer depends on compiler. Which means if the compiler use 16 bit address line then size of pointer is 2bytes like turbo c .if compiler use 32bit address line then the size of pointer is 4 bytes like gcc or if it use 64 bit address line the size of it is 8 bytes like morden gcc. So the size of pointer is only depends on address line of compiler not depends on anything else.
NULL pointer points to nothing whereas Dangling pointer points to non-existing memory (here is an analogy, if u have an empty chips packet then its Dangling pointer whereas if u don't even have a chips packet then its null pointer)
^^yes. Dangling pointer points to a memory address that previously existed, and now does not. Hence it will lead to unpredictable runtime results if dereferenced. This is very, very bad. NULL pointer, is a pointer that points to NULL (technically, the 0 address or “invalid” address in code). This address does not store variables or data of any kind.
Is it not incorrect to say that it doesn't point to any memory location since if you look at the memory layout of an operating system a null pointer would be the area beneath the Text/Code segment? Wouldn't it be more correct to say "which points to an invalid memory location" ?
At 2:43, suppose we declare "ptr" as a void pointer.... Then also, we have to typecast "ptr" to get 0 as output without getting errors????? For example: int main() { void *ptr=NULL; printf("%d", (int*)ptr); return 0; } 👆 Like this????
Like the above, in the case of heap memory allocation, should a malloc or realloc call fail, they will return a NULL pointer instead. So it is good industry practice to check if this returned pointer, to a temporary variable, is NULL; and only if not NULL you may reassign your pointer location to it. Hence to keep the integrity of the data/program. It is rare, though possible, for heap memory to run out-especially in code outside of practice or isolated/protected/separated sessions.
in an integer array, i want to use null to avoid getting out of range of the array. but i can't use it. because for example, i created an array has 12 members. so the first index is 0 and the last index is 11. when it's getting out of range, for example arr[12] is existing. you can try it. it gives random numbers every time i run the program. so null is not suitable in this case.
Excellent course, better than any University !! the whole c programming in one course , amazing .. recommended for beginners and advanced also
This channel is a blessing for all engineering students ❤️
A great learning channel....Its like a boon for me....Thankyou so much for working so hard.
Excellent teacher you're sir ji🙏🙏🙏❤️❤️
Additional points
1.null pointer is a pointer which points to the memory.where that memory is allocated to OS. We can't assign a memory to already reserved memory for OS. So why it's called null pointer
2.The size of pointer depends on compiler. Which means if the compiler use 16 bit address line then size of pointer is 2bytes like turbo c .if compiler use 32bit address line then the size of pointer is 4 bytes like gcc or if it use 64 bit address line the size of it is 8 bytes like morden gcc. So the size of pointer is only depends on address line of compiler not depends on anything else.
Sir ur my best teacher in life because I feel fail this subject by u I got confidence
Very helpful video about NULL pointer 😇
Best explanation on youtube let me tell you
Nice..need more topics of data Structure
this is great let me tell you
The best explanation ever for real
Thanks
very helped
Great explained .....
very good....I mean what a lecture 👍🏻
thank you sir
Please upload the whole course as soon as possible please sir 🙏🙏🙏🙏🙏🙏
thx bro!
Difference between Null pointer and Dangling pointer??? by looking at the definition, it's seems to be same.
NULL pointer points to nothing whereas Dangling pointer points to non-existing memory (here is an analogy, if u have an empty chips packet then its Dangling pointer whereas if u don't even have a chips packet then its null pointer)
^^yes. Dangling pointer points to a memory address that previously existed, and now does not. Hence it will lead to unpredictable runtime results if dereferenced. This is very, very bad. NULL pointer, is a pointer that points to NULL (technically, the 0 address or “invalid” address in code). This address does not store variables or data of any kind.
i love this guy let me tell you
Exclusive video
Excellent
Hi sir plz upload all the videos soon plz plz,my humble request
ThankYou Sir!
Is it not incorrect to say that it doesn't point to any memory location since if you look at the memory layout of an operating system a null pointer would be the area beneath the Text/Code segment? Wouldn't it be more correct to say "which points to an invalid memory location" ?
Yes, it points to the address 0 which is the very first address of the memory
0:47
1:12
2:10
3:05
3:29
Thx
amazing
Thnq sir
Why should you do a null check before dereferencing a pointer, if it’s null isn’t it going to dereference to 0 anyways
What is null pointer assignment error in c?
At 2:43, suppose we declare "ptr" as a void pointer.... Then also, we have to typecast "ptr" to get 0 as output without getting errors?????
For example:
int main() {
void *ptr=NULL;
printf("%d", (int*)ptr);
return 0;
}
👆 Like this????
Upload daily sir
Who can explain me what are the differences of below snippet
Ptr == NULL
*Ptr == \0
When I try to initialise a pointer to NULL i get this error: ‘NULL’ undeclared (first use in this function)
why there is no * in fact 1 while printing the pointer.
Can any body explain what is null check
It's Checking , whether that certain pointer was null, in other words, The memory can access is 0, So no more space.
Like the above, in the case of heap memory allocation, should a malloc or realloc call fail, they will return a NULL pointer instead. So it is good industry practice to check if this returned pointer, to a temporary variable, is NULL; and only if not NULL you may reassign your pointer location to it. Hence to keep the integrity of the data/program. It is rare, though possible, for heap memory to run out-especially in code outside of practice or isolated/protected/separated sessions.
the way he pronounced "a null" is very funny
2:59 there is segmentation fault in vscode
Because it’s dangerous to assign value to an uninitialised pointer ( Segmentation Fault)
Yeah when you (try to) manipulate data extraneous to the area that you should access. You’re not allowed. Hence seg fault.
1:42 *ptr=NULL;
should be correct during initialization.
Malloc returns NULL when there is no more memory available, so this is correct
❤
🎉
in an integer array, i want to use null to avoid getting out of range of the array. but i can't use it. because for example, i created an array has 12 members. so the first index is 0 and the last index is 11. when it's getting out of range, for example arr[12] is existing. you can try it. it gives random numbers every time i run the program. so null is not suitable in this case.
arr[12] is giving you random numbers as it's containing garbage data as your array hasn't been allocated that memory chunk.
^^ it’s accessing memory outside of its semantically restricted area.
Saaray paisay LET ME TELL YOU kay hain, otherwise best explaination veeray..
how can u explain with malloc func as we dont know that topic
im really need this for sims 3 download im keep get a error im download
dont repeat every line... its annoying, ...you could've explain this in mere 2 minutes...
iddis waddis
That would've been more confusing and fast!
Watch it at 1.5x then
👎