in reply to OT: Why does malloc always give me 24? [SOLVED]
What's the size of "int" on your system? It's nearly always best to use types with defined sizes, like int32_t.
Also, i can' exactly make sense of what you are trying to do here. You are only allocating a single element. My "memory managment in C" is quite rusty, but if you want an array with N elements of type acme, i think it should be more in the line of this:
#define N 10 typedef struct _acme { int data; } acme; acme *gizmo; gizmo* = (acme*)malloc(sizeof(acme) * N);
But as i said, it's been a long time and i wrote this from memory.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: OT: Why does malloc always give me 24?
by etj (Priest) on Aug 18, 2024 at 16:36 UTC |