Message from C, C++ discussions

December 2019

— Missed a returned value

— 

Hey guys I already know C language and now I want to extend my knowledge to C++ so which book is best to start learning C++ best in the sense which gives reference and comparision with C and not covering same topic in depth again like pointers, arrays etc..

— Psst

— Lol why you don't use monospace font

— Void fun(int arr[])
{
int i;
int arr_size = sizeof(arr)/sizeof(arr[0]);
printf("%d\n",sizeof(arr));
printf("%d\n",sizeof(arr[0]));
for (i = 0; i < arr_size; i++)
printf("%d ", arr[i]);
}

int main()
{
int i;
int arr[4] = {10, 20 ,30, 40};
fun(arr);
return 0;
}

Message permanent page

— OUTPUT produces 8 4 and 10 20

— Can someone explain me how 8 is the size of the array

— Wtf

— Don't use sizeof/sizeof

— It doesn't work

— Use a variable to pass the size

— Why are you trying to calculate the size of array when you already know? pass an extra argument in the function for array size

Message permanent page