0

I've made a struct, and I wanted to make an array of that struct, I tried allocating memory using malloc() but it doesn't seem to allocate the requested memory.

#include<stdio.h>
#include<stdlib.h>

typedef struct Players{
    int level_;
    char name_[15];
    float progress_;
    float health_;
} player;

int main()
{
    player *n =  malloc(2 * sizeof(player));
    printf("%d \n", sizeof(n));

    free(n);

    return 0;
}

the allocated memory is 8, instead of 56.

Am I missing something?

Ma250
  • 355
  • 1
  • 4
  • 11

0 Answers0