c - Malloc Member Array of Struct -


i have struct , dynamic array inside struct. want malloc array don't how. want array void because want members of array structs. can see tried doesn't work

#include <stdio.h> #include <stdlib.h> #include <string.h>  struct saf  {   int head;   void **stack;   int size; }exp1;    void init(int n) {     struct saf exp1->stack = malloc(n);  }  int main() {   printf("give size: ");  scanf("%d",&exp1.size);  init(exp1.size);  return 0; } 

exp1 isn't pointer. use

exp1.stack = malloc(n); 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -