How its possible to get last two strings from PIN, without using char, really don`t have any idea, i need it because, my program will select men or women with that last two strings…
#include "CWorker.h"
#include <iostream>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
void CWorker::setData() {
cin.ignore();
cout << "\tEnter name of the employee: "; getline(cin, name);
cout << "Enter Personal Identity number: "; getline(cin, PIN);
cout << "Enter daily peyment for the employee: "; cin >> dailyPayment;
cout << "Enter work days for the employee: "; cin >> workDays;
}
void CWorker::getData() {
cout << "\tName of the employee: " << name << endl;
cout << "Personal id. number on the employee is: " << PIN << endl;
cout << "Daily payment for the employ1ee: " << dailyPayment << endl;
cout << "Work days for the employee: " << workDays << endl;
}
void CWorker::pin();
i share only part of my CPP fail but rly i had no idea how to deal with this function pin.
>Solution :
I guess PIN is a string. To get the last 2 digits
std::string last2 = PIN.substr(PIN.length() - 2, 2);
if PIN is a number then do
string PINs = std::to_string(PIN);
std::string last2 = PINs.substr(PINs.length() - 2, 2);