the idea behind deleting data from a program?

This is a discussion on the idea behind deleting data from a program? within the C Programming forums, part of the General Programming Boards category; Hi guys I have a list of student data stored under struct-variable of type std: Code: typedef struct{ char name; ...

  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
    32,855
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,528
    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).
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



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-30-2008, 12:02 AM
  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, 05:03 PM
  4. Deleting downcast not invoking destructor - any idea?
    By Imperito in forum C++ Programming
    Replies: 3
    Last Post: 05-10-2002, 03:44 PM
  5. Deleting data from a structure?
    By bluebob in forum C Programming
    Replies: 7
    Last Post: 05-09-2002, 04:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21