I think you meant:
string str = 100;
Sorting is pretty easy with the help of the standard library. You can start by writing a function object that compares the first characters of two strings:
Then, in say, your main() function you can call std::sort() from the <algorithm> header, instantiating a CompareByFirstChar function object as you do so:
bool operator()(const std::string& x, const std::string& y) const
return x < y; // Assume all strings have at least 1 character.
Incidentally, it looks like you are not handling your files properly. You have one myfil fstream object in the scope of main(), and another in the scope of a while loop in main(). You are probably looking to write a loop along these lines:
sort(str, str + 100, CompareByFirstChar());
// ... read into file ...
cout << "file could not be opened. enter the name of another file in the format filename.txt:";
cin >> file;