//input.h文件:实现从D盘的express.txt文件的写入和读出,在D盘下建个express.txt文件,里面存入一串字符,如:#2*20+3*(30/3)#5(两边的#必不可少);再建个evaluation.txt文件,用于存结果。
#ifndef __INPUT__
#define __INPUT__
int Input(char **express);
int Output(int evaluation);
#endif
//input.cpp文件
#include "stdafx.h"
int Input(char **express)
{
FILE* fp;
static char str[100];
fp = fopen("D:\\express.txt","r");
if (fp == NULL)
{
printf("\n inputed express.txt doesn't exist");
return -1;
}
//Read Cal Expression Information
fscanf(fp,"%s,",str);
fclose(fp);
*express = str;
return 0;
}
int Output(int evaluation)
{
FILE* fp = fopen("d:\\evaluation.txt","w");
fprintf(fp,"%d ",evaluation);
printf("%d", evaluation);
fclose(fp);
return 0;
}
//Stack.h文件,两个栈的类