0001 char* removeSpace ( char* s ) { //剔除s[]中的白空格 0002 char* p = s, *q = s; 0003 while ( true ) { 0004 while ( isspace ( *q ) ) q++; 0005 if ( '\0' == *q ) { *p = '\0'; return s; } 0006 *p++ = *q++; 0007 } 0008 } 0009 0010 int main ( int argc, char* argv[] ) { //表达式求值(入口) 0011 for ( int i = 1; i < argc; i++ ) { //逐一处理各命令行参数(表达式) 0012 char* rpn = ( char* ) malloc ( sizeof ( char ) * 1 ); rpn[0] = '\0'; //逆波兰表达式 0013 float value = evaluate ( removeSpace ( argv[i] ), rpn ); //求值 0014 free ( rpn ); rpn = NULL; 0015 } 0016 return 0; 0017 }