Note that this is a simple program for learning how to delete an array element, so we don't do any input validation. We could check to make sure that total entered is less than MAX_CAPACITY and greater than 0 using an if statement for example. We could also add a check to ensure the user entered an int value at all instead of something like "abc". But these things are left out of this video to focus on the problem of deleting the element. 🙂
@lemmenmin7676 Жыл бұрын
if (delete_index > total) also
@PortfolioCourses Жыл бұрын
Yep, same idea. :-)
@OCEAN-fc9wl Жыл бұрын
Had a C programming exam yesterday and your videos helped me a lot!
@PortfolioCourses Жыл бұрын
That's awesome! :-) Thank you for sharing that with me, the biggest reason I love making these videos is that they might help students and beginner programs, so it's excellent for me to hear that the videos helped you out.
@wonderfulworld24759 ай бұрын
Thank God for Java & Python with their string & array functionalities.
@naboulsikhalid7763 Жыл бұрын
Unbelievable, so clear and understandable. thank you
@PortfolioCourses Жыл бұрын
You’re welcome Naboulsi, I’m glad the video was clear and understandable for you! :-)
@jayasuryaliftАй бұрын
if the size is 5 and i input 5 as the deleting element there should nothing to delete so can you gave that code
@fabimawn Жыл бұрын
I started learning C this week after mastering Lua, and if I watch BroCode's C course, and want to know all the specifics of a something in C, you are now my go to!!!. I got some questions though. I understood that besides setting pointers to NULL, there is no way besides ASM to wipe them out of RAM (or allocating space to the adresses again), now here in this video example if you want to delete an element, you can't really from what I understood. When writing a program that might generate milions of new variables, and deletes others every time, doesn't RAM slowly fill up? How is that generally managed?
@PortfolioCourses Жыл бұрын
We use what's called dynamic memory allocation to make sure that RAM does not "fill up". We allocate space to store data, and then when we are done working with it, we can free the space using free() to make it available again for other uses. This video covers dynamic memory allocation: kzbin.info/www/bejne/iGHUeoyNpJ2cndU. Also, I'm sure BroCode's C course is great, but just you know this is a full course on C you can watch too: kzbin.info/www/bejne/qaStimiDebGdotE. :-)
@mayanksrivastava754010 ай бұрын
I am sorry but how are we supposed to account for the last element in array because the declaration which we initially did(arr i = arr (i + 1) ) will work for every element except for the last element . This will happen so because the last element is supposed to be given a value which is not even there in array . It would be great if you could clear my doubt . Thank you!
@safaabdalah331710 ай бұрын
He answered it in the video and he actually brought up this very scenario. Because we are keeping track of how many elements are in the array even if there is still an element at the end we dont have to deal with it. When we print out whats in the array it will only print out 5 elements even if there is a 6th element in there at the end.
@USAmerica-777 Жыл бұрын
I have a question: Is there a way to get rid of the last trailing element after the data is shifted forward? The "4" still remains in memory at array[5] after the data in the array is shifted. Is there a way to free the array[5]? Also, I wanted to say I have been watching your videos since last semester lol. And thanks to you I have been able to pass all my classes. I am taking Data structure and Algo this semester. I definately feel my skills have improved and its all thanks to u! You have all these videos on how to do basic things in C; if i get confused I come here to your channel and I know what needs to be done. Thank you for these videos!
@PortfolioCourses Жыл бұрын
Great question! :-) We could set the element to 0, or some other special value that we interpret as "unused". But we can't really free the memory for that element when we have an array on the stack. If we were using dynamically allocated memory, we could use realloc() to decrease the size of the array. This video covers realloc: kzbin.info/www/bejne/rKOaonaHgdeIqpo. And thank you so much for the kind feedback, I'm really glad to hear you enjoy the videos. My biggest motivation for making this channel was to reach and help out students like you with their programming classes, so it really means a lot to me to know these videos have helped you out. :-)
@deczhu34259 ай бұрын
memcpy or memmove
@not_hakurei123627 күн бұрын
So basically you dont actually remove the element, you just ignore it?
@cowdumdum Жыл бұрын
thanks for the video
@PortfolioCourses Жыл бұрын
You're welcome! :-)
@pranavc747 Жыл бұрын
Python users be like: pop()
@PortfolioCourses Жыл бұрын
It's wild, I know they are different languages that typically solve different problems, but every time I go to make a Python video I'm reminded just how easy it is to do simple things compared to C. It's like driving a car in manual vs automatic. :-)