1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I have to define 1 structure

Discussion in 'C' started by shaliwahan.patil, Dec 14, 2007.

  1. shaliwahan.patil

    shaliwahan.patil New Member

    Joined:
    Dec 14, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    See the Problem:

    C Programming
    I have to define 1 structure


    typedef struct
    {
    int roll;
    char *name;
    }stud;

    stud s1;


    now for this rollno, and character pointer i have to enter value &store it in file, in this way store many records should be entered , &I should be able to add, modify, delete & display the records fromfile using same structure. memory leckage & dangalling pointer errorshould not come.

    I have tried a lot but it is not working, so please see if you can help out.

    but the thing is that it must be a character pointer only not acharacter array. is it possible???

    Using character array I have done the same but not using pointer in CProgramming.

    rest is ok..
     
  2. Salem

    Salem New Member

    Joined:
    Nov 15, 2007
    Messages:
    133
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Please don't PM me for 1:1 support.
    Well if you've already managed to do this with a char array, then you're already half way.

    When you have a pointer, it is all about making sure enough memory is allocated when you want to assign to that name, and that the memory is freed when you no longer need the structure.

    Post some code, and don't forget to use [code][/code] tags.
     

Share This Page