VS2015链接器错误怎么解决
总显示这个错误,在百度和stackoverflow里看的问题基本上都是出在链接器没有使用console,但是我建立的确实是一个控制台类应用,使用的也是console,我另外建了一个小程序,运行之后也是显示这个错误,似乎我的VS2015某处设置出了问题。我想知道问题出在了哪里,该怎么解决?源码如下://采用算符优先算法解决该问题
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<assert.h>
#define TRUE 1
#define FALSE 0
/*创建两个堆栈,一个用于存储运算数,另一个用于存储运算符
创建用于存储运算数的结构体*/
typedef struct OPNUM
{
double opnum;
struct OPNUM* next;
} Opnum;
/*创建用于存储运算符的结构体*/
typedef struct OPCHAR
{
char opchar;
struct OPCHAR*next;
}Opchar;
Opnum* numt = NULL;
Opchar* chart = NULL;
//操作数压入函数
void pushn(double num)
{
Opnum*new_opnum;
new_opnum = malloc(sizeof(Opnum));
assert(new_opnum != NULL);
new_opnum->opnum = num;
new_opnum->next = numt;
numt = new_opnum;
}
//操作符压入函数
void pushc(char opchar)
{
Opchar*new_opchar;
new_opchar = malloc(sizeof(Opchar));
assert(new_opchar != NULL);
new_opchar->opchar = opchar;
new_opchar->next = chart;
chart = new_opchar;
}
//操作数弹出函数
double popn(void)
{
double saven = numt->opnum;
Opnum*stack;
stack = numt;
numt = numt->next;
free(stack);
return saven;
}
//操作符弹出函数
char popc(void)
{
char savec = chart->opchar;
Opchar*stack;
stack = chart;
chart = chart->next;
free(stack);
return savec;
}
//运算模块函数
double operat(double numa, char opchar, double numb)
{
switch (opchar)
{
case'+':return numa + numb;
case'-':return numa - numb;
case'*':return numa*numb;
case'/':return numa / numb;
}
}
//运算符比较模块函数,opchar1为栈顶元素,opchar2将被判断是否入栈,
char compare(char opchar1, char opchar2)
{
char Prior[7][7] =
{ // 运算符优先级表,
// '+' '-' '*' '/' '(' ')' '#'
/*'+'*/'>','>','<','<','<','>','>',
/*'-'*/'>','>','<','<','<','>','>',
/*'*'*/'>','>','>','>','<','>','>',
/*'/'*/'>','>','>','>','<','>','>',
/*'('*/'<','<','<','<','<','=',' ',
/*')'*/'>','>','>','>',' ','>','>',
/*'#'*/'<','<','<','<','<',' ','='
};
char opchar[7] = { '+','-','*','/','(',')','#' };
int i, x, y;
for (i = 0; i<7; i++)
{
if (opchar[i] == opchar1)
x = i;
if (opchar[i] == opchar2)
y = i;
}
return Prior[x][y];
}
//判断一个输入的字符究竟是运算数还是运算符
int isnum(char* input)
{
if (input > '0'&&input < '9')
return TRUE;
return FALSE;
}
//算符优先法模块
double operator_precedence_method(char* input_string)
{
char *current = input_string;
char **currentp;
double num;
double result;
chart = malloc(sizeof(Opchar));
assert(chart != NULL);
chart->opchar = '#';
while (*current != '\n')
{
if (isnum(current))
{
num = strtod(current, currentp);
current = *currentp;
pushn(num);
}
else
{
if (compare(chart->opchar, *current) == '<')
{
pushc(*current);
current++;
}
if (compare(chart->opchar, *current) == '>')
{
result = operat(popn(), popc(), popn());
pushn(result);
pushc(*current);
current++;
}
if (compare(chart->opchar, *current) == '=')
{
popc();
popc();
}
if (compare(chart->opchar, *current) == ' ')
{
printf("error!");
return EXIT_FAILURE;
}
}
}
return result;
}
//主函数
int main(void)
{
int result;
char string[256];
printf("请输入表达式:");
fgets(string, 256, stdin);
result = operator_precedence_method(string);
printf("结果为%d", result);
getch();
return EXIT_SUCCESS;
}