c语言程序运行出错,求大神帮忙
#include<stdio.h>#include<string.h>
int ids(char *m)/*identify size*/
{
int n;
if(strcmp(m,"1/2")==0||strcmp(m,"0.5")==0)
n=0;
if(strcmp(m,"3/4")==0||strcmp(m,"0.75")==0)
n=1;
if(strcmp(m,"1")==0)
n=2;
if(strcmp(m,"1-1/2")==0||strcmp(m,"1.5")==0)
n=3;
if(strcmp(m,"2")==0)
n=4;
if(strcmp(m,"2-1/2")==0||strcmp(m,"2.5")==0)
n=5;
if(strcmp(m,"3")==0)
n=6;
if(strcmp(m,"3-1/2")==0||strcmp(m,"3.5")==0)
n=7;
if(strcmp(m,"4")==0)
n=8;
if(strcmp(m,"4-1/2")==0)
n=9;
if(strcmp(m,"5")==0)
n=10;
if(strcmp(m,"6")==0)
n=11;
if(strcmp(m,"7")==0)
n=12;
if(strcmp(m,"8")==0)
n=13;
if(strcmp(m,"9")==0)
n=14;
if(strcmp(m,"10")==0)
n=15;
return n;
}
int idc(char *p)/*identify class*/
{
int q;
if(strcmp(p,"1")==0)
q=0;
if(strcmp(p,"2")==0)
q=1;
if(strcmp(p,"3")==0)
q=2;
if(strcmp(p,"4")==0)
q=3;
if(strcmp(p,"5")==0)
q=4;
if(strcmp(p,"6")==0)
q=5;
return q;
}
void main()
{
int i,j; int cou=0;//计算有多少行数据要处理
char a[100][5],b[100][5],c[100][5];
int g,h,k,l,m,x,y;
int leap1,leap2,leap3,leap4;
char (*array1)[5];
char (*array2)[5];
char type[100][20]={0};
FILE *fp1;/*input*/
fp1=fopen("in.txt","r");
if(fp1==NULL)
{
printf("file open error!\n");
return ;//文件不存在就退出系统
}
for(i=0;i<100 ;i++,cou++)//cou在这里计算得出
{ if(EOF==fscanf(fp1,"%s\n",type[i]))//如果读到空行就退出循环
break; //
printf("%s\n",type[i]);
}
fclose(fp1);
leap1=leap2=leap3=leap4=1;
for(i=0;i<cou;i++)//resolve
{
g=h=k=l=m=j=0;
while(leap1&&j<20)
{
if(type[i][j]<'A'||type[i][j]>'Z')
{
a[i][g]=type[i][j];j++;g++;
}
else
{
j++;leap1=0;
}
}
while(leap2&&j<20)
{
if(type[i][j]>='A'&&type[i][j]<='Z')
{
b[i][h]=type[i][j];j++;h++;
}
else
{
j++;leap2=0;
}
}
while(leap3&&j<20)
{
if(type[i][j]>='0'&&type[i][j]<='9')
{
c[i][k]=type[i][j];j++;k++;
}
else
{
j++;leap3=0;
}
}
while(leap4&&j<20)
{
if(type[i][j]>='A'&&type[i][j]<='Z')
{
b[i][h]=type[i][j];j++;h++;
}
else
{
j=j+2;leap4=0;
}
}
while(type[i][j]>'0'&&type[i][j]<'9'||type[i][j]>='A'&&type[i][j]<='Z')//distinguish'\'
{
b[i][h]=type[i][j];
j++;
h++;
}
*array1=a[100][5];
*array2=c[100][5];
x=ids(array1);
y=idc(array2);
printf("%d\n%d\n",x,y);
}
}
目的是为了一串字符分解开来,如1-1/2X3Y,MN12这种类型,首先是一个整数或分数,小数,然后第二是1-3个字母,然后第三是一个整数,第四是字母,第五是逗号,第六逗号之后的数不确定。程序目的是把逗号之前的字母和逗号后的所有内容分到同一个二维数组中,把字符串中两个数字分别放到两个数组中。但是下面这程序可以读入数组,但是算法好像不能执行,运行结束后结果应该是x=3 y=2,能麻烦看下算法吗?是不是我二维数组的指针用错了?