为什么不能将交换函数中的临时变量定义为指针???
void swap(int *a, int *b)
{
int *tmp;
*tmp = *a;
*a = *b;
*b = *tmp;
}
gcc之后执行"./a.out"报错"Segmentation fault (core dumped)"
void swap(int *a, int *b)
{
int *tmp;
*tmp = *a;
*a = *b;
*b = *tmp;
}
gcc之后执行"./a.out"报错"Segmentation fault (core dumped)"
2018-05-07
举报