Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   I have to define 1 structure (http://www.go4expert.com/forums/i-define-1-structure-t7844/)

shaliwahan.patil 14Dec2007 14:39

I have to define 1 structure
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..

Salem 14Dec2007 16:14

Re: I have to define 1 structure
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.

All times are GMT +5.5. The time now is 07:10.