Delete An Array Element At A Specific Index | C Programming Example

  Рет қаралды 22,115

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 21
@PortfolioCourses
@PortfolioCourses Жыл бұрын
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
@lemmenmin7676 Жыл бұрын
if (delete_index > total) also
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Yep, same idea. :-)
@OCEAN-fc9wl
@OCEAN-fc9wl Жыл бұрын
Had a C programming exam yesterday and your videos helped me a lot!
@PortfolioCourses
@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.
@wonderfulworld2475
@wonderfulworld2475 9 ай бұрын
Thank God for Java & Python with their string & array functionalities.
@naboulsikhalid7763
@naboulsikhalid7763 Жыл бұрын
Unbelievable, so clear and understandable. thank you
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re welcome Naboulsi, I’m glad the video was clear and understandable for you! :-)
@jayasuryalift
@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
@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
@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. :-)
@mayanksrivastava7540
@mayanksrivastava7540 10 ай бұрын
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!
@safaabdalah3317
@safaabdalah3317 10 ай бұрын
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
@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
@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. :-)
@deczhu3425
@deczhu3425 9 ай бұрын
memcpy or memmove
@not_hakurei1236
@not_hakurei1236 27 күн бұрын
So basically you dont actually remove the element, you just ignore it?
@cowdumdum
@cowdumdum Жыл бұрын
thanks for the video
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome! :-)
@pranavc747
@pranavc747 Жыл бұрын
Python users be like: pop()
@PortfolioCourses
@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. :-)
37 - DELETION OF AN ELEMENT FROM A SPECIFIC POSITION IN AN ARRAY - C PROGRAMMING
15:15
路飞做的坏事被拆穿了 #路飞#海贼王
00:41
路飞与唐舞桐
Рет қаралды 26 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 50 МЛН
Master Array Element Deletion in C Program in Just 5 Minutes!
5:14
Delete An Array Element At Specified Index With C#
3:49
Program Snippets
Рет қаралды 1,5 М.
Dynamically Allocate Memory For An Array Of Strings | C Programming Example
12:10
Program for deleting element from array in C
10:59
EduFlair KTU CS
Рет қаралды 10 М.
struct Basics | C Programming Tutorial
24:44
Portfolio Courses
Рет қаралды 154 М.
Bubble Sort | C Programming Example
14:53
Portfolio Courses
Рет қаралды 133 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 837 М.
Bubble Sort  | Logical Programming in C | Naresh IT
11:10
Naresh i Technologies
Рет қаралды 501 М.