This statement
if(words[j+1].(int)name[0]<words[j].(int)name[0]){
is syntactically invalid. The correct statement will look the following way
if( ( int )words[j+1].name[0]<( int )words[j].name[0]){
However there is no any sense to make such a record because (the C++ Standard)
The usual arithmetic conversions are performed on operands of
arithmetic or enumeration type
On the other hand if type char behave as signed char and your array can contain characters with negative values then the sorting will be invalid. I advice to rewrite the statement the following way
if( ( unsigned char )words[j+1].name[0]<( unsigned char )words[j].name[0]){
Also these statement are invalid
temp=words[j].name;
words[j].name=words[j+1].name;
words[j+1].name=temp;
Arrays (variable temp shall be defined as char[20]) have no the assignment operator. Either use standard C function strcpy or define the arrays as std::array<char,20>
For example (you need include header
strcpy( temp, words[j].name );
strcpy( words[j].name, words[j+1].name );
strcpy( words[j+1].name, temp );
Or ( you need include header )
struct Words{
array<char, 20> name;
};
array<char, 20> temp;
temp=words[j].name;
words[j].name=words[j+1].name;
words[j+1].name=temp;
3
solved Alphabetically sorting the words