mre / the-coding-interview

Programming exercises, code katas and puzzles for your job interview training - or just for fun.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C array size must be passed as a second argument

Yanpas opened this issue · comments

From bubble sort code:

void bubblesort(int *v){

    int i,j,aux;

    int size = sizeof(v) / sizeof(v[0]); // Number of indexes in the V array.

sizeof(int*) is always equal to size required for holding memory address (8bytes on 64bit arch). There should be second arg size_t v_len.

BTW (int v[]), (int v[static 5]), (int v[20]) etc. are all internally transformed to (int* v)

Hm... could you create a pull request for that @Yanpas? Would help me greatly in fixing this. Thank you very much for your report. 😃