I have to define 1 structure

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

  1. shaliwahan.patil

    shaliwahan.patil New Member

    Dec 14, 2007
    Likes Received:
    Trophy Points:
    See the Problem:

    C Programming
    I have to define 1 structure

    typedef struct
    int roll;
    char *name;

    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

    Nov 15, 2007
    Likes Received:
    Trophy Points:
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice