Hello! I have a problem that needs me to load a char array from a file, make every line of that array into a string, and then sort the strings.
needs to turn into
I have the character array loaded fine, I am just not sure how to turn it into four different strings that I can then sort?
The actual problem uses a  array. So I was trying to figure out a way to use a for loop to create the strings. I think I may just be ignorant to some part of string properties. I have all the libraries included.
Bottom line for now, I just need to figure out how to "load" a new string value with a range of chars.
To illustrate a little more... in my mind I am trying to do this:
string line1(array[0-3]) in order to get line1="bgtf" (from the top array)
Obviously this isn't working for me, and I am pretty sure I am just doing it wrong and lack the proper syntax.
It seems my instructor is pretty insistent on utilizing a character array. The character array is .
I need to load the array from a file, which I've done.
I thought I could just convert each line of the array into a string, sort the strings and be done with it. But I can, he wants the same routine that prints the original array to print the sorted array.
I have figured out how to turn them all into strings, and I imagine ill be able to sort the strings. What I do not know how to do, is convert the 10 strings back into a character array that can be printed by the original print function that read the file. But I am sure there is a way.
So if I have string line1, line2, line3, line4 from my original example: After its sorted, it would need to display in the order of line3, line1, line2, line4. So I need to reload a char array in that order. How would I do that.
Or is there some clever way to sort only the order precedence of the rows in a two dimensional char array without ever converting it to strings?
Thank you so much in advance. This one really has me scratching my head.
We have barely touched vectors and have not touched pointers. So I dont think I am supposed to use either.
If you are using character arrays rather than std::string, you might do things using the functions which work with c-strings, such as strcpy() to copy a string, and strcmp() to compare two strings. That way you might tackle this without using std::string or std::vector and so on.