寻求error LNK2001: unresolved external symbol _main解决办法
向各位大侠请教了,我的程序是这样的:#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#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<ntn; 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<ntn; 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;
}
}
目的在于想根据单词的出现频率按降序打印输入的各个不同单词,并在每个单词的前面标上它的出现次数。
可vc编译器总是出现:
error LNK2001: unresolved external symbol "void __cdecl treestore(struct tnode *)" (?treestore@@YAXPAUtnode@@@Z)与
fatal error LNK1120: 1 unresolved externals
上网找了其他资料,但并不能解决,现在莱鸟想向高手请教了!