我正在编写合并 2 个排序数组的代码,代码如下
void main()
{
int a[]={7};
int b[] = {8};
int ret;
int *c;
merge(a,b,c,1,1);
}
void merge(int *a, int *b,int *sorted, int i, int j)
{
int c1,c2,k=0;
c1=0;
c2=0;
for(k=0;c1<i && c2< j;k++)
{
if(a[c1]<b[c2])
sorted[k]=a[c1++];
else
sorted[k]=b[c2++];
}
while(c1<i)
sorted[k++]=a[c1++];
while(c2<j)
sorted[k++]=b[j++];
}
运行此代码程序时停止,我得到以下异常
Problem Event Name: APPCRASH
Application Name: merge.exe
Application Version: 0.0.0.0
Application Timestamp: 556fb91c
Fault Module Name: merge.exe
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 556fb91c
Exception Code: c0000005
Exception Offset: 00001739
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 2057
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
如何修复它