i re edit the code and theses are the errors im recieving.
41"expected primary-expression before "students"
41"expected primary-expression before '&' token
and the same for line 71 .
plus "roster" undeclared.
80 [Warning] statement is a reference, not call, to function `exit'
[Build Error] [main.o] Error 1
I believe im not declaring or passing the struct and the ifstream correctly into the function but since im pretty new to both concepts im at a loss on the proper way to pass the argument.
So with this layout below how would you pass the if stream from the main to the function ( or would you open the file in main at all?), then using struct search the file for a name? Im sorry for the inconvenience in advance. novice programming disorder
1) Open file only in concrete functions.
Or
2) Make every function in call chain (progMenu and studentSearch) to take reference to istream and pass roster to it.
You were on the right track in your first post when you were passing student and roster. The only problem was that you were mixing fstream and ifstream type.
As to whether to open roster in main or elsewhere, that depends on how you're using it. If you're going to open it, read all the records and close it, then that is usually done in the same function. If you intend to open it then read it when you need to, then it makes sense to put the open in main. What you want to avoid is opening the file every time you want to look up a student. Opening a file can be expensive on some operating systems.