-
The fundamentals of your program are broken anyway. No point in having input and output working if you read the data, munge it, and then write it out.
When you tell people to get in a line, in order of age, those people don't assign their ages to someone else.
-
i'm trying not to use linked lists...i don't understand it!
-
You can't sort records in memory unless you actually have more than one of them in memory.
You can store the records in an array, a list, a binary tree, a skip-list, or ..... but one way another you have to learn about the data structure that you choose to use. Generally an array is about the simplest choice, but with an unknown number of records, one way or another you are going to have to learn dynamic memory allocation i.e. malloc & free.
Another option is disk-based sorting, but even then you need to have at least two records in memory at once in order to compare them, and of course you either have to modify the existing file, or write it out to a new file.
If you still find none of that appealing, then I suggest you switch to C++, where this kind of thing is a piece of cake. You either learn how to use the language you've chosen, or you don't.