Help please

I need the code for alphabetic sorting..
What are you sorting? Is it a vector, string, a char array, is it stored in a file?
Give us something to work with please.
Also at least post a little bit of your own code so we know where you're starting from.
Last edited on
newbieg is right... Not enough information...
Still... take a look here (hope this is what you want):

http://www.cplusplus.com/forum/beginner/12089/
#include<iostream>
#include<string>
using namespace std;
struct data{
string name[10];
int number ;
float average ;
}student[3];
void reading(data)
{
for(int i=0;i<3;i++)
{
getline(cin,*student[i].name) ;
cin >> student[i].number ;
cin >> student[i].average;
}
}
int sorting(data student[3]){
int i,j;
string k;
for(i=0;i<3;i++){
for(j=1;j<=3;j++){
if(student[i].name[0] > student[j].name[0]){
k = *student[i].name;
*student[i].name = *student[j].name;
*student[j].name = k;}}}
return 0;}
void printing(data student[3]){
for(int i=0;i<3;i++){
cout << student[i].name << '\t' << student[i].number << '\t' << student[i].average << endl;
}}
int main()
{
data *student[3];
cout << reading(*student[3]);
cout << sorting(*student[3]);
cout << printing();
return 0;
}
Please, Put this thread into the correct section. There is nothing to do with Windows API nor even included any Windows header files. This should be in beginner section rather than here.

Next the concept of your homework is pretty simple if you write it out on paper before typing code.

You should not be asking for code snippets this early in Programming. I and other members here programmed for almost a decade and we still do not ask for Code. Trust me the logic is pretty straightforward.

GL
Last edited on
Topic archived. No new replies allowed.