看看这个C,我真无语了

来源:百度知道 编辑:UC知道 时间:2024/07/04 01:58:06
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

struct Value
{
int i_value;
char ope_value;
int flag; //1 for int,2 for operator,0 for nothing
};
typedef struct Value Value;

int isoperator(char c){
return ( c=='+'||c=='-'||c=='*'||c=='\');
}

struct Value& word_analysis(char* input){
struct Value value;
value.flag = 0;
if(!(isdigit(input[0]) && isoperator(input[0]))){
printf("Input symbol Error!");
return value;
}
}

int main(){
return 0;
}

debug说问题如下:
H:\my doc\作业\编译\Syntax\parse.cpp(16) : error C2001: newline in constant
H:\my doc\作业\编译\Syntax\parse.cpp(17) : error C2143: syntax error : missing ')' before '}'
H:\my doc\作业\编译\Syntax&#

H:\my doc\作业\编译\Syntax\parse.cpp(16) : error C2001: newline in constant
H:\my doc\作业\编译\Syntax\parse.cpp(17) : error C2143: syntax error : missing ')' before '}'
H:\my doc\作业\编译\Syntax\parse.cpp(17) : error C2143: syntax error : missing ';' before '}'

以上错误是因为
return ( c=='+'||c=='-'||c=='*'||c=='\');
最后的'\'应该写成'\\'.

H:\my doc\作业\编译\Syntax\parse.cpp(24) : warning C4172: returning address of local variable or temporary
以上错误是因为return value;中的value是局部变量的地址, 它只在本函数内部才有效, 不能返回到外部.
将struct Value value; 改成 static struct Value value; 就可以了.

'\' 是错误写法

字符 \ 应该用 '\\' 来表示

'\' ,第一个单引号作起始单引号,\ 作转义,\' 表示字符 ', 然后编译程序发现少了一个结束单引号啊

这个程序不全,有一些打字错误,但从这些代码可以看出,编写这个程序的人,有一定编程素养!