I am learning C and I want to do this specific task. I know there is a number of similar questions and answers, but still... I will try to be more specific. Lets say, I have a file with following lines:
program01 programs aprogram 1program prog 5program And I want now an array with:
1program 5program aprogram prog program01 programs So there are ONLY latin small letters and numbers in strings, no spaces. I know how to perform some separate steps, but want to get and feel the whole (and proper) concept, so to say. Probably it could make some sorting decisions on the fly when reading from file first? Manual sort is preferred for my particular case, just for the sake of better learning and possible optimisation. Lets say, maximal length of one line is 256, maximal number of lines is 256. Thanks in advance.
char buffer[256][256 + 2]2) callfgets()up to 256 times. 3)qsort(). 4) Print the lines.char*is just a byte array and I can compare each char just like an int. Would be easy to compare two strings. But I just found it hard to understand some sorting examples due to my lack of C syntax knowledge, especially pointer arithmetic.