main.c
/* 就近匹配,找出不匹配的符号用箭头A标注出来 这里只写了小括号的匹配 */ #define _CRT_SECURE_NO_WARNING #include<stdio.h> #include<stdlib.h> #include<string.h> #include"Stack.h" typedef struct MYCHAR { StackNode node; char* pAddres; int index; }MyChar; int IsLeft(char c) { return c == '('; } int IsRight(char c) { return c == ')'; } MyChar* CreatMyChar(char* p, int index) { MyChar* mychar = (MyChar*)malloc(sizeof(MyChar)); mychar->pAddres = p; mychar->index = index; return mychar; } void ShowError(char* str, int pos) { printf("%s ", str); for (int i = 0; i < pos; i++) { printf(" "); } printf("A"); } int main() { //char* str1 = "#include<stdio.h> int main(){int a[4][4];int (*p)[4];p=a[0];return 0;}"; char* str = "1+2+6(desa)ads)e(rfsd)"; //创建栈容器 LinkStack* stack = InitStack(); char* p = str; SElemType* e = (SElemType*)malloc(sizeof(SElemType)); int index = 0; while (*p != '