we are in a section were we are working with classes also with arrays my question is if you have an array of students how can you remove that student for the list by copying the other students for below up a slot.

Recommended Answers

All 4 Replies

When the elements of the array are moved (or copied) up a slot that will overwrite whatever was there before. That does not make the arrray smaller, it just means the last array element is left empty, or unused.

thats exactly what i want to do so what would the code look like if i had to search for the student and remove it from the list

Think about it, then try to write the problem yourself. Post YOUR code with whatever question(s) you may have. Please deposit $10,000.00USD in my PayPal account and I'll write that for you :)

Use 2 indexes, 1 for 'student', 1 for 'new position'. Start them both at 0.
Increment both indices until you find the student you want to remove.
Increment only the student index.
Now continue to the end of the array copying the values in the 'student' index into the positions of the 'new position' index.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.