Message from C, C++ discussions
December 2019
— User Daniyal has 1/2 warnings; be careful!
The latest warn was because:
whatsapp chat
Void recursionBubble(int* arr, int size, int i, int j, int n){
printf("i = %d n = %d\n", i, n);
if(i >= size / sizeof(int)){
return;
}else{
if(n >= size / sizeof(int))recursionBubble(arr, size, i + 1, 0, 1);
if(arr[n] < arr[j]){
swap(&arr[n], &arr[j]);
recursionBubble(arr, size, i, j + 1, n + 1);
}else{
recursionBubble(arr, size, i, j + 1, n + 1);
}
}
}
— Why do i get seg fault
— (why i am getting to infinite recursion)
— Your debugger is broken ?
— Https://www.geeksforgeeks.org/c-language-2-gq/advanced-pointer-c-gq/
— Why are you dividing by sizeof(int)
? It doesn't make sense to me
— Because i gave to the function
sizeof(arr)
and not
sizeof(arr) / sizeof(int)
— But if it is a pointer, it returns the size of the pointer (probably 8), and if it's an array, it should return the amount of ints
— So either way, the code is not doing what you think
— I just started C language, is there any place for me to fully learn
— Www.google.com