I have an assignment for my programming class where I need to take an existing text file, extract each line individually, sort them in alphabetical order, and then put all the lines into a new text file in alphabetical order. The two parts I am having trouble with are taking each line out of the file (there are thousands of lines) and putting them into a vector of strings. If I could get the vector with all the lines in it, I know how to sort it alphabetically, but once that is done, I don't know how to write the new sorted lines into a new text file. Any help would be appreciated. The file is an Apache web log taken from a web server.
It can not be replaced with just "int" because "int" is signed and size_t is unsigned - but you can use "unsigned int". The problem is that on some compilers and operating systems, size_t might not be an unsigned int, so to be sure you use size_t always and not just plain unsigned int.