I'm new to C and have stumbled over a problem I can't get a grip of. I've written a function that reads floating point numbers from a file and put them in a allocated (malloc) match_t array. It works fine so far. But when writing a unit test for it (yes wrong order, I know), strange things happens. Code: typedef struct match_s { double home; double draw; double away; } match_t; Code: void test_readMatchStats() { int c; match_t *matchArray; match_t facit[] = { {0.11, 0.12, 0.13}, {0.21, 0.22, 0.23}, {0.31, 0.32, 0.33}, {0.41, 0.42, 0.43}, {0.51, 0.52, 0.53} }; matchArray = readMatchStats("test.txt"); ... } When the facit array gets over 4 in legth I get a segmentation fault, otherwise it works. If I comment out the call to readMatchStats, I can make it bigger. Why is that?