小编use*_*996的帖子

我的程序崩溃,我不明白为什么它甚至没有到达第一个printf

我的程序应该订购一个由用户输入的数字列表,但它甚至在到达第一个printf之前就崩溃了.我的编译器发出2个警告,但我没有看到问题.我还没有研究过指针,所以我不想使用它们.以下是消息:

在函数`selection_sort'中:

[Warning] passing arg 2 of `selection_sort' makes pointer from integer without a cast 
Run Code Online (Sandbox Code Playgroud)

在函数`main'中:

[Warning] passing arg 2 of `selection_sort' makes pointer from integer without a cast 
Run Code Online (Sandbox Code Playgroud)

.

#include<stdio.h>

int selection_sort(int n, int v[n])
{
    int high = v[0];
    int i;

    for(i = 0; i < n; i++)
        high = high < v[i]? v[i] : high;

    if(n - 1 == 0)
        return;

     v[n - 1] = high;
     n -= 1;

     selection_sort(n, v[n]);
}   



int main(void)
{   
    int n, …
Run Code Online (Sandbox Code Playgroud)

c function

3
推荐指数
1
解决办法
111
查看次数

标签 统计

c ×1

function ×1