how can ı sort a student list from a text file like StudentList.txt according to students' surname and id number.can ypu help me?

Recommended Answers

All 2 Replies

>>can ypu help me?
Yes. But first you need to post the code you have tried to solve the problem. We are not a program manufacturer.

this is my program codes:

#include <iostream>
#include <string>
#include <stack>
#include <cctype>


using namespace std;

// The following defns should go into a .h file

#define PrintWrtSurname "ps"
#define PrintWrtId "pi"
#define AddStudent "i"
#define DeleteStudent "d"
#define Quit "q"

void editStudentList(/* StudentList&*/)
{
	string command;

	cout << "Student Registration System " << endl;

	  for(;;){
	  cout << "Enter a command: " << endl;
      cin >> command;

	 

	  if(command == PrintWrtSurname){
	  
		  // StudentList.printwrtSurname(); //
		  cout << "done printing w.r.t surname" << endl;}

	  else if(command == PrintWrtId){
	  
		  // StudentList.printwrtId(); //
		  cout << "done printing w.r.t id" << endl;}

		else if (command == Quit){

				cout << "done " << endl;
				return;}
			
			 else cout << "no such command as: " << command << endl;
	  }
}


int main(){

	// StudentList	cmpe160;

	// createStudentList("studentFile.txt", cmpe160);

	editStudentList(/* cmpe160 */);
      
      return 0;
}

this is the student list:

2007100307,	OGUZ 	,CEYLAN ,	cet
2005100700,	HASAN ,	COSKUN ,	tt
2008400024,DUYGU ,ALGAN ,	cmpe
2007101336, BETUL ,ARI ,cmpe
2006104564,ERCAN ,	AY ,	ee
2008400180,	ERVIN 	,DOMAZET,man
2004102743,AHMET FAIK, 	BAK ,	cmpe
2007100631, EMRECAN ,BATI ,cee
2004104291,	TURGAY, 	CAN ,	cet
2003104024,ERSIN,	AYDIN ,	ee
2006104624,AHMET ,	AYDIN ,	cmpe
2008400033,	HAKAN ,	DEMIR ,	man
2007100625,	ENES BAHADIR ,	DISBUDAK ,	man
2003104471,HASAN,ELMAS,man
2007102347ESRA 	,ARSLAN ,cmpe
2005100736,REMZI	,ASCI ,ee
2006102371,	BULUT 	,DEMIR ,	ptw
2007100934,ISMAIL, ATKURT ,ee
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.