the directions was to:
1. enter name of student into array of string; size is
60
-enter size of array
-surname first name, middle initial
2. display names
3.sort names alphabetically
4. exit program
this is what i did;
my proffesor told me:Code:# include <iostream.h> # include <string.h> # include <conio.h> struct names{ char name[20]; }; void bubble(); int main(){ bubble(); return 0; } void bubble(){ int n; char temp[20]; cout<<"How many names are you going to insert?"<<endl; cin>>n; names * array=new names[n]; for(int i=0;i<n;i++) { cout<<"Give me the name"<<endl; cin>>array[i].name; } for (int x=1 ; x<n ; x++) for (int y=0 ; y<n-x ; y++) if ( strcmp ( array[y].name, array[y+1].name) > 0){ strcpy( temp,array[y].name); strcpy( array[y].name, array[y+1].name ); strcpy( array[y+1].name, temp ); } for(int a=0;a<n;a++){ cout<<"The sorted names are: "<<array[a].name<<endl; } getch(); }
i should be able to type the name, middle name, & surname into an array that has the size of 60
i used cin, i should just use c++
i should follow directions
he said all i did was 1 & 3