指针数组问题,查询时说野指针有问题,没理解什么意思,请各位指教
#include<stdio.h>#include<string.h>
#define n 3
int main()
{
void dispose(char *b[n]);
char *a[n];
for (int i = 0; i<n; i++)
{
scanf_s("%s", a[i]);
}
dispose(a);
for (int i = 0; i<n; i++)
printf("%s", a[i]);
return 0;
}
void dispose(char *b[n])
{
char t[100];
for (int i = 0; i<n - 1; i++)
{
for (int j = 0; j<n - 1 - j; j++)
if (strcmp(b[i], b[i + 1])>0)
{
strcpy_s(t,sizeof(t),b[i + 1]);
strcpy_s(b[i + 1],sizeof(b[i+1]),b[i]);
strcpy_s(b[i], sizeof(b[i]),t);
}
}
}