c语言错误lnk2001,寻求error LNK2001: unresolved external symbol _main解决办法

不知道你在说什么,

也不知道你明白我刚才说什么了没有。

把你的程序改好的给你贴上,自己比较吧。

注意:是没有编译错误,运行错误自己解决啊。

#include

#include

#include

#include

#define MAXWORD 100

#define BUFSIZE 1000

#define NDISTINCT 1000

int getch(void);

void ungetch(int c);

int comment(void);

int getword(char *word, int lim);

struct tnode *talloc(void);

char *strdup(char *s);

struct tnode *addtree(struct tnode *p, char *w);

void treestore(struct tnode *p);

void sortlist();

struct tnode *list[NDISTINCT];

int ntn = 0;

char buf[BUFSIZE];

int bufp = 0;

struct tnode {

char *word;

int count;

struct tnode *left;

struct tnode *right;

};

main()

{

struct tnode *root;

char word[MAXWORD];

int i;

root = NULL;

while (getword(word, MAXWORD) != EOF)

if (isalpha(word[0]))

root = addtree(root, word);

treestore(root);

sortlist();

for (i=0; i

printf("%2d:%20s\n",list[i]->count, list[i]->word);

return 0;

}

int getch(void)

{

if (bufp > 0)

return buf[--bufp];

else

return getchar();

}

void ungetch(int c)

{

if (bufp >= BUFSIZE)

printf("ungetch: too many characters\n");

else

buf[bufp++] = c;

}

int comment(void)

{

int c;

while ((c = getch()) != EOF)

if (c == '*')

if ((c = getch()) == '/')

break;

else

ungetch(c);

return c;

}

int getword(char *word, int lim)

{

int c;

char *w = word;

while (isspace(c = getch()))

;

if (c != EOF)

*w++ = c;

if (!isalpha(c)) {

*w = '\0';

return c;

}

for ( ; --lim > 0; w++)

if (!isalnum(*w = getch())) {

ungetch(*w);

break;

}

*w = '\0';

return word[0];

}

struct tnode *talloc(void)

{

return (struct tnode *) malloc(sizeof(struct tnode));

}

char *strdup(char *s)

{

char *p;

p = (char *) malloc(strlen(s)+1);

if (p != NULL)

strcpy(p, s);

return p;

}

struct tnode *addtree(struct tnode *p, char *w)

{

int cond;

if (p == NULL) {

p = talloc();

p->word = strdup(w);

p->count = 1;

p->left = p->right = NULL;

} else if ((cond = strcmp(w, p->word)) == 0)

p->count++;

else if (cond < 0)

p->left = addtree(p->left, w);

else

p->right = addtree(p->right, w);

return p;

}

void treesorte(struct tnode *p)

{

if (p != NULL) {

treesorte(p->left);

printf("%4d %s\n", p->count, p->word);

treesorte(p->right);

}

}

void sortlist()

{

int gap, i, j;

struct tnode *temp;

for (gap = ntn/2; gap > 0; gap /= 2)

for (i=gap; i

for (j=i-gap; j>=0; j-=gap) {

if ((list[j]->count) >= (list[j+gap]->count))

break;

temp = list[j+gap];

list[j] = list[j+gap];

list[j+gap] = temp;

}

}

void treestore(struct tnode *p)

{

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值