我的代码是这样的时候:程序崩溃试图运行我的代码的特定部分
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
char ** djiksin(char ** inp){
}
int evaluation(char ** rpn){
}
void printarr(char arr[]){
int i=0;
while(arr[i] != '\0'){
printf("%c",arr[i]);
++i;
}
}
int main(){
int i = 0,k = 0,j=0;
char a[201] = {'\0'};
char ** strinp;
fgets(a,201,stdin);
while(a[i] != '\0'){
if(a[i] == '(' || a[i] == ')' || a[i] == '*'|| a[i] == '+'|| a[i] == '^'|| a[i] == '~'|| a[i] == '/'|| a[i] == '-'){
j = 0;
k = k+1;
strinp[k][j] = a[i];
k = k + 1;
}else if(a[i] == ' '){
k = k + 1;
j = 0;
}else{
strinp[k][j] = a[i];
j = j+1;
}
++i;
}
printarr(a);
return 0;
}
代码的用途迄今采取mathmethical公式,并格式化为使用调车场alghorithm。这在我脑海中试图让每个操作符和操作数分开。 最后,strictp应该给出一串字符串,我可以在我之前声明的函数中使用它。
但每次我尝试编译&运行测试程序后,我把输入窗口给出的错误“程序停止工作”。关闭错误后,该输出在命令提示符:Process exited after 3.871 seconds with return value 3221225477
当我在main
发表意见while
部分代码工作只是适当的输出罚款。
有什么想法?
最简单的解决方案是使striinp成为一个二维阵列。类似于strictp [100] [201]。 –