Sunday, August 22, 2010

How do i write a self defining data structure for a linked linear list data structure in C language?

I also want to use the self defining structure to create a linked list to perform the following functions on the list:


i. Insert data items into the list. Input should be terminated by a zero ii. Delete a specified item from the list iii.Modify a specified item in the list iv. Print the list.

How do i write a self defining data structure for a linked linear list data structure in C language?
I'm not sure what you mean by "self defining data structure"


unless you're pointing out that the "node" of a linked list


contains pointers to it's own type. If it's more than that, then


maybe my answer won't be sufficient; however, I think


what you're asking for is a data structure like:





struct node {


void* data;


struct node* next;


};





If you visit the following web page, you'll find an explanation


of this (and other variations), including source code for


insertion, deletion, search, etc.





http://stsdas.stsci.edu/bps/linked_list....
Reply:Sounds to me like you want to do a template class, so that you can define which data type to store in your linked list "on the fly". Here's a tutorial about templates:





http://www.devarticles.com/c/a/Cplusplus...





Oh, it is in C++. But I thought maybe that's what you meant, because I wouldn't know what "self-defining data structure" is otherwise.
Reply:Seems like you are making a database software. Like a library or dictionary program. Most likely you will need iostream.h and stdio.h as header then use multidimensional arrays to store the result. as for printing use printf or if you save the data on a file


fprintf.


But if I tell you more you will have to pay/employ me :).


An advice: Think on the data structures before you create the program.


No comments:

Post a Comment