Thread: the idea behind deleting data from a program?

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    25

    the idea behind deleting data from a program?

    Hi guys


    I have a list of student data stored under struct-variable of type std:

    Code:
    typedef struct{
    
    char name; 
    
    char surname;
    
    float grade;
    
    }std;
    later on main program, I declared some variable std1,std2....std30. of std type that can get filled out by the user.

    now I wanna get some Menu (using switch). one of the cases here is to link the user to a program, where they can delete data (students) from the existing student list.

    can you help me how to do that? is it possible to delete it directly without copying all data in an extern file?

    Would be grateful for any hint

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > later on main program, I declared some variable std1,std2....std30. of std type that can get filled out by the user.
    Well it gets a lot easier if you use an array.

    Then to delete a student, all you do is
    student[i] = student[i+1];
    student[i+1] = student[i+2]; // except you would do this in a loop, stopping at numStudents


    and student[i] is no more.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by Aitra View Post
    now I wanna get some Menu (using switch). one of the cases here is to link the user to a program, where they can delete data (students) from the existing student list.

    can you help me how to do that? is it possible to delete it directly without copying all data in an extern file?

    Would be grateful for any hint
    What you need here is a way of organizing the data, a data structure.
    Linked lists or plain arrays would do it..(each with their own way of deleting).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deleting all data in a struct array
    By grimuth in forum C++ Programming
    Replies: 11
    Last Post: 03-29-2008, 11:02 PM
  2. Deleting Variable Data
    By column in forum C++ Programming
    Replies: 3
    Last Post: 02-13-2006, 05:12 PM
  3. IDEA: Data (De)Compressor
    By ygfperson in forum Contests Board
    Replies: 10
    Last Post: 08-20-2002, 04:03 PM
  4. Deleting downcast not invoking destructor - any idea?
    By Imperito in forum C++ Programming
    Replies: 3
    Last Post: 05-10-2002, 02:44 PM
  5. Deleting data from a structure?
    By bluebob in forum C Programming
    Replies: 7
    Last Post: 05-09-2002, 03:00 PM