int var_lib_check(char *type, char *var)
{
static char var_library[MAX_VARS][MAX_LINE];
static char new_var[MAX_LINE];
static int num_of_var;
int z;
if (strcmp(type, DOUBLE_TYPE) == 0 || strcmp(type, INT_TYPE) == 0 ||
strcmp(type, RTRN_TYPE)==0)
{
for (z = 0 ; z < num_of_var ; z++)
{
if (strcmp(var_library[z], var) == 0)
{
sprintf(new_var, "x%d", z);
printf("%s %s\n", type, new_var);
return z;
}
}
strcpy(var_library[num_of_var], var);
sprintf(new_var, "x%d", num_of_var);
printf("%s %s\n", type, new_var);
num_of_var += 1;
}
return num_of_var;
}
如何修改我的var_lib_check()
以将变量名称替换应用于另一个类语句:来自表达式的赋值语句是单个变量,总和,乘积,除法,两个变量的减法?
例如:
double malcolm; would be double x0;.
int zoe; would be int x1;.
zoe=wash; would be x1=x2;.
malcolm=wash*river; would be x0=x2*x3;.