I have a question...How can I use an array of structs?I managed to create it,but I cannot use it in scanf and printf...I will post here only the part of my code that is necessary...
The main function is:
int main()
{
int r;
struct word *s;
s=(struct word*)malloc(sizeof(struct word));
struct word hashtable[100];
s->name=(char*)malloc(20*sizeof(char));
scanf("%s",s->name);
r=hashnumber(s->name);
char *name="example.txt";
if(hashtable[r]->name==NULL)
treecreation(&hashtable[r],s);
else
hashtable[r]=s;
printf("%s",hashtable[r]->name);
printresults();
system("pause");
return(0);
}
struct word is:
struct position
{
char *filename;
int line;
int place;
struct position *next;
};
struct word
{
char *name;
struct word *right;
struct word *left;
struct position *result;
};
And function treecreation is like:
void treecreation(struct word **w1,struct word *w2)
Do not bother with the rest of my functions...I believe that they work...The main problem is how to use that array of structs...Right now,my program does not compile,because of the "if" statement,the "treecreation" and the printf..What should I do?Any help would be appreciated...