Kodewick
Start learning →
Starter←→0 / 60

Airport code

#018StarterStrings2 min

The first three letters on a luggage tag are the airport code, like PEK in PEK-0815. Write airport_code(ticket) to return those three. The tag always has at least 3 characters.

Examples
airport_code("PEK-0815")→'PEK'
airport_code("LHR")→'LHR'
The functionstring airport_code(const string &ticket)
main.cpp
#include <string>
using namespace std;

string airport_code(const string &ticket) {
    string code = "";
    // your code here: take the first 3 characters with substr
    return code;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.