where user inputs random words (200 being the max size of the input and 10 is the max size of each word)
where number is the number of each word occurs in the input
i thought it would be as simple as the following but boy was i wrong
1 2 3 4 5 6 7 8 9 10
for (int i = 0; i < number - 1; i++)
{
int min = i;
for (int j = i + 1; j < number; j++)
if (strings[j] < strings[min])
min = j;
string temp = strings[i];
strings[i] = strings[min];
strings[min] = temp;
}
i guess above code only works for 1d array of strings, and i don't think we've touched on 2d arrays in class (let alone c-strings), and i couldnt find it in the chapter ;/
conceptually what you have is a 1-d array of c-strings. the fact that the string itself is an array may be confusing you a little. Does this help you when thinking about it? Its the same as an array of ints, in that regard... only difference is the comparison function for the c-strings is a little wonky (c++ strings fix this). a 2-d array of strings is a 3-d char array, do you see this?