All pastes #59839 Raw Edit

Miscellany

public text v1 · immutable
#59839 ·published 2006-05-30 07:54 UTC
rendered paste body
/* I can't code C for shit ^^ */

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

typedef struct {
	int *data;
} array;

main()
{
  array arr;
  char txt[]="Test";

  array_grow(arr, &txt);
  
  printf("%d\n", arr.data[0]);
}

int array_grow(array arr, int value)
{
  if ((arr.data = malloc(sizeof(value))) == NULL) {
    exit(1);
  }
  arr.data[0] = value;
}