fix segmentation fault on hw4/3.c