By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Search results

  1. X

    C Does type before malloc even matter ?

    Hello ! I've been testing some stuff with pointers. Here is one of them : #include <stdio.h> #include <stdlib.h> int main() { int *matrix = (int *)malloc(1); *(matrix) = 2562323; printf("%d", *matrix); return 0; } I tried to check if the output will be an error because...
  2. X

    C [C] byte address range.

    PS. For the second example when I write size of(arr) it will say it has 8 bytes although for arr[0] it takes 4 bytes because there are 4 addresses for 4 letters. But it says it's size is 8 bytes what ??? Even though if I write (arr + 1) it will go 1 byte (for example arr[0] is 55ae7f302008 so...
  3. X

    C [C] byte address range.

    Hello ! I am struggeling with understanding how this works : #include <stdio.h> #include <stdlib.h> int main() { int rows = 2; int columns = 5; int **matrix = (int **) malloc(rows * sizeof(int *)); matrix[0] = (int *) malloc(rows * columns * sizeof(int)); for (int i = 1...
  4. X

    I don't understand multi dimensional arrays using pointers and pointers in arrays

    I tried to understand these two codes : int *pv = (int*) malloc(5 * sizeof(int)); for(int i=0; i<5; i++) { pv[i] = i+1; } This is a one dimensional array. And I am confused of how malloc works and why it is also a pointer (int *) ?? Because I had more simple examples such as...
Top Bottom