for some reason it crashes in the terminal but not on code::blocks, seg fault in a for loop