我的问题就是 输入数据到数组之后 无法进行下一步 找不到问题在哪
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
int match(char* str)
{
char stackMemroy[1024];
int top = -1;
int i = 0;
while (str[i] != '\0')
{
if (str[i] == ')')
{
if (top > -1)
{
top --;
}
else
{
return -1;
}
}
else if (str[i] == '(')
{
stackMemroy[++top] = str[i];
}
i++;
}
if (top == -1)
return 0;
else
return 1;
}
int main()
{
while (1)
{
char str[1024] = "";
/*get_s(str, 1024);*/
scanf_s("%s",str);
int result = match(str);
if (result == 0)
{
printf("匹配\n");
}
else if (result == 1)
{
printf("多了左边括号\n");
}
else
{
printf("多了右边括号\n");
}
}
return 0;
}