A file namedeptdat stores first names and departments for so
A file \"namedept.dat\" stores first names and departments for some employers of a car dealership (seperated by the pound sign). A script is being written to read the information from the file into a vector variable (\"employees\") of structures; each structure has the fields for the name and departments. In order to be efficient, the vector is preallocated to have 50 elements (although this should later be reduce to the actual number of elements used). You are to write the script to read each line from the file using fgetl, and put the information from each line into a structure that is stored in the vector.
Solution
fid = fopen(\'namedpt.dat\');
%reading file
%processing each line
line=fgetl(fid);
ix=1; % iterator counter variable declared
while line ~= -1
Vector{ix}=line; %storing into vecor
line=fgetl(fid);
ix=ix + 1; %incrementing iterator counter to move next location
end
fclose(fid); %closing file pointer
