【发布时间】:2014-07-12 11:11:55
【问题描述】:
我有一个问题...如何使用结构数组?我设法创建了它,但我无法在 scanf 和 printf 中使用它...我将仅在此处发布我的代码中必要的部分...
主要功能是:
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 position
{
char *filename;
int line;
int place;
struct position *next;
};
struct word
{
char *name;
struct word *right;
struct word *left;
struct position *result;
};
而函数树创建是这样的:
void treecreation(struct word **w1,struct word *w2)
不要打扰我的其他功能...我相信它们可以工作...主要问题是如何使用该结构数组...现在,我的程序无法编译,因为“ if”语句,“treecreation”和printf ..我该怎么办?任何帮助将不胜感激...
【问题讨论】: