Click here to Skip to main content
15,895,011 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: I'm a newbee on this site... Pin
Matthew Faithfull6-Dec-07 3:44
Matthew Faithfull6-Dec-07 3:44 
GeneralRe: I'm a newbee on this site... Pin
toxcct6-Dec-07 3:45
toxcct6-Dec-07 3:45 
GeneralRe: I'm a newbee on this site... Pin
Hamid_RT6-Dec-07 3:58
Hamid_RT6-Dec-07 3:58 
Generalhttps problem Pin
Sundararajan6-Dec-07 3:16
Sundararajan6-Dec-07 3:16 
AnswerDelete Elements in arrays Pin
KARFER6-Dec-07 3:09
KARFER6-Dec-07 3:09 
GeneralRe: Delete Elements in arrays Pin
Cedric Moonen6-Dec-07 3:14
Cedric Moonen6-Dec-07 3:14 
GeneralRe: Delete Elements in arrays Pin
Maximilien6-Dec-07 3:20
Maximilien6-Dec-07 3:20 
GeneralRe: Delete Elements in arrays Pin
CPallini6-Dec-07 3:25
mveCPallini6-Dec-07 3:25 
Since the array is allocated onto the stack you cannot delete (i.e. remove) items. However you can erase the info wherein, for instance:
...
for (int i=0;i<100;i++)
{
  if (member[i].number == search)
  {
    member[i].number = -1; // Using -1 to mark 'deleted' items
    memset( member[i].name, 0, 50); // erase name
    memset( member[i].address, 0, 30); // erase address
    break; // only if you're sure numbers are unique
  }
}
...


You can also use an old (soft removing) trick: swap the found item content with the (currently) last one and decrease the element count.

BTW: don't use explicitely numbers (eg. 50, ...) in code, use meaningful symbolic consts instead (e.g. NAME_SIZE, ...).

Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.


GeneralRe: Delete Elements in arrays Pin
toxcct6-Dec-07 3:36
toxcct6-Dec-07 3:36 
GeneralSure, buddy! Pin
CPallini6-Dec-07 3:51
mveCPallini6-Dec-07 3:51 
GeneralRe: Sure, buddy! Pin
toxcct6-Dec-07 4:26
toxcct6-Dec-07 4:26 
GeneralRe: Sure, buddy! Pin
CPallini6-Dec-07 4:51
mveCPallini6-Dec-07 4:51 
GeneralRe: Sure, buddy! Pin
toxcct6-Dec-07 5:54
toxcct6-Dec-07 5:54 
GeneralRe: Delete Elements in arrays Pin
KARFER6-Dec-07 5:29
KARFER6-Dec-07 5:29 
GeneralRe: Delete Elements in arrays Pin
CPallini6-Dec-07 5:40
mveCPallini6-Dec-07 5:40 
Generaltls with ftp in vc++ Pin
gayathri6-Dec-07 2:46
gayathri6-Dec-07 2:46 
GeneralRe: tls with ftp in vc++ Pin
Mike Dimmick6-Dec-07 3:54
Mike Dimmick6-Dec-07 3:54 
GeneralChild process problem Pin
maladuk6-Dec-07 2:23
maladuk6-Dec-07 2:23 
GeneralRe: Child process problem Pin
David Crow6-Dec-07 2:35
David Crow6-Dec-07 2:35 
GeneralRe: Child process problem Pin
maladuk6-Dec-07 2:44
maladuk6-Dec-07 2:44 
GeneralRe: Child process problem Pin
David Crow6-Dec-07 2:48
David Crow6-Dec-07 2:48 
GeneralRe: Child process problem Pin
maladuk6-Dec-07 3:04
maladuk6-Dec-07 3:04 
QuestionRe: Child process problem Pin
David Crow6-Dec-07 4:59
David Crow6-Dec-07 4:59 
AnswerRe: Child process problem [modified] Pin
Member 75496011-Dec-07 5:58
Member 75496011-Dec-07 5:58 
GeneralPutting values in array Pin
vjasai6-Dec-07 1:48
vjasai6-Dec-07 1:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.