Help! - FILE - sort alphabetically
Hello everyone!
I'm learning programming in C and now I have a some troubles with FILES. I searched a lot of tutorials in Google and YouTube but I really didn't understand how to solve some problems.
I have to solve an exercise that says:
In a File I have millon of names (they're not ordered alphabetically) and I have to print only the first 100 sorted alphabetically. The file is a .txt
I can only use ONE array.
I think I have to do this:
First, I sort the first 100 names alphabetically and I save them in an array (alphabetically).
Then, I go to the name 101 and I see if it's higher or lower than 100. If it's higher, the array continues like it was. If it's lower, I check it to the number 99. If it's higher, I put that name in the position 100 and I clean the name that was there. I can do that with a for.
To compare the names, I think that "strcmp" would be perfect
Can anyone help me with the code?
Thank you VERY MUCH,
Juan
ps. I hope you understand what I wrote haha