Hi there, I have to create a structure which includes student last name, his average mark and cipher whose first 2 letters indicates faculty in which student is studying.I have to read the data from a file and find a group of people from 1 faculty and sort them according to they average mark from biggest to smallest. Can anyone help? Maybe you have done familiar task? The hardest thing for me to read the file with structure and find people from 1 faculty.
The structure is like that
[struct studentas{
char lastname[30];
float aver;
char group[10];
};]
and the file example would be like that: Collins 8.5 PFSU
Johns 5.4 EFSU
and so on. PF stands for Physics faculty and the further text doesn't matter.
WilliamMorris - if you read enough posts on this board you'll find that help is not usually given unless the OP demonstrates some tangible effort of his/her own. Copying/pasting the original assignment does not count as such
I'm not asking to write a whole program. I'm asking to explain how to do it, a hint I guess, if a person writes a whole program it's not my problem. I have only written which parts I don't understand( read the file with structure and find people from 1 faculty).
Your appear to have defined two functions called void printing(student s,int n)
and I would suspect the first one (which precedes the ifstream fd line) should probably be void reading(student s, int n)
It then goes into a loop from i=0 to n-1; however, you don't appear to have set n anywhere. It is not clear whether you intend to pass that from main() or read it from file or do something else.
So the short answer to your question is that it won't print anything in a new file because it didn't read anything in an old file.
That said, you do seem to have taken gunnerfunner's advice and the code is beginning to look structured.
Well, I made the first mistake because i wanted to rewrite the program in english and i havent noticed that and one of my biggest problems is not the understanding but the lack of knowledge.. I haven't done anything with structures and programming for couple years :D