1. I wonder whats the problem. Has no error and warning.. but can not sort names. Why? Whats the mistake(s)? "red color"
2. why if i use tolower the character.. got problem...whats the problem? "blue color"
thank you in advance...
#include <iostream>
#include <string>
using namespace std;
int main()
{
string *name;
string temp;
int num;
/* ********Enter number of students*********** */
cout << "Please enter the numbers of student: ";
cin >> num;
name = new string [num];
/* *********Sorting names by alphabet************* */
for (int i=0; i < num; i++)
{
cout << "Enter student name [" << i+1 << "]: ";
getline(cin,name);
name = tolower(name);
}
for (int pass=0; pass <3; pass++)
for (int i=0; i <3; i++)
if ( name > name[i+1] )
{
temp = name;
name = name[i+1];
name[i+1] = temp;
}
for (int a=0; a < num ; a++)
cout << name[a] << endl;
cout << "\nList of student <sorted>:\n";
for ( i = 0; i < num; i++ )
cout << name << endl;
/* ********* Listing names that contain "Mo "************ */
cout << "\nList of student name that contains the string Mo:\n";
for ( int b= 0; b < num; b++ )
{
if ( name.find( "mo" ) == 0 )
cout << name << endl;
}
delete [] name;
return 0;
}