求助,c程序编译执行出错
小弟在编写一个C程序的时候,发现执行的时候,总是出错,错误是“xx.exe已停止工作”具体程序如下:#include <stdio.h>
#include <string.h>
void expand(char* s1,char* s2)
{
int i,j;
char temp;
for(i = 0;i < strlen(s1) - 1; )
{
if( (s1[i] == '-') && s1[i+2] != '-')
{
temp = s1[++i] ;
for( ; s2[j++] != temp; )
{
s2[j] = s2[j-1] + 1;
}
i = i + 2;
}
else if( (s1[i] == '-') && s1[i+2] == '-')
{
temp = s1[i+3] ;
for( ; s2[j++] != temp; )
{
s2[j] = s2[j-1] - 1;
}
i = i + 4;
}
else
{
s2[j++] = s1[i++];
}
}
}
main()
{
char s1[] = "a-z0-9";
char s2[100];
expand(s1,s2);
printf("Now S1 is %s and S2 is %s",s1,s2);
}
所用的编译环境是DEV-Cpp(4.9.9.2),操作系统是win7