Since you defined your student structure inside of main, how will your SkriverTilFil() know anything about this structure? Your structure needs to be defined before it can be used, and by defining this structure in a function it is only available inside that function. No other function will be able to use it. So I recommend you define your structures outside of any function and before any function that will require this structure.