自己写了一个程序,编译出来没有错误了,但是一运行就会出现0xC0000005:Access viol
ation.请教大家这是怎么回事啊?谢谢啊。
程序如下:
#include<stdio.h>
#include<iostream.h>
#include<string.h>
char len='a'-'A';
void trans(char *a)
{
if((*a)>'Z'){*a=*a-len;}
}
void check(char *p)
{trans(p);
char str1[27],str2[26];
char alph[26]={'A','B','C','D','E','F','G','H','I','K','L','M','N','O','P','Q
','R','S','T','U','V','W','X','Y','Z','\0'};
int i,j;
i=0;
str1[i]=*p;
p++;
i++;
in:while(*p)
{trans(p);
for(j=0;j<i;j++)
{if(str1[j]==*p)
{p++;goto in;}
else continue;}
str1[i]=*p;i++;p++;
};
if(!(*p))
{int k;
char *q;
int m=0;
q=alph;
on:while(*q)
{
for(k=0;k<=i;k++)
{if(*q==str1[k])
{q++;goto on;}
else continue;}
str2[m]=*q;q++;m++;
};
}
strcat(str1,str2);
int n=0;
for(n=0;n<=25;n++)
cout<<str1[n]<<endl;
}
void main()
{char buf[200];
cout<<"please input the key:"<<endl;
scanf("%s",buf);
check(buf);
printf("\n");
char a ;
cin>>a;
}