Skip to content

Instantly share code, notes, and snippets.

@Bojne
Last active November 23, 2017 13:04
Show Gist options
  • Save Bojne/72da9d28c11fc865f1483ea4ffd94964 to your computer and use it in GitHub Desktop.
Save Bojne/72da9d28c11fc865f1483ea4ffd94964 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using namespace std;
string user_input;
string regis_year, campus, course, faculty;
void display(string regis_year,string campus,string course, string faculty);
int main(){
cout << "Please enter your registration number below and press enrer.\n";
cin >> user_input;
int end_index = user_input.find('/',0);
faculty = user_input.substr(0,end_index);
int beg_index = end_index;//Store beg_index to end_index
end_index = user_input.find('/',end_index+1);//Iterate end_index
course = user_input.substr(beg_index+1,end_index-beg_index-1);
beg_index = end_index;
end_index = user_input.find('/',end_index+1);
campus = user_input.substr(beg_index+1,end_index-beg_index-1);
regis_year = user_input.substr(user_input.find(".")+1,-1);
//cout << beg_index<<endl;
//cout << end_index<<endl;
//cout << faculty << endl;
//cout << regis_year<< endl;
//cout << campus << endl;
//find
//sybstr
display(regis_year, campus,course,faculty);
return 0;
}
void display(string regis_year,string campus,string course, string faculty){
cout << endl<< "Registrered_year: "<<regis_year<<endl;
cout << "Campus: " << campus << endl;
cout << "Course: " << course << endl;
cout << "Faculty: " << faculty << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment