could someone try explain the what the difference between these two pieces of codes is?
// Example program
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
char keypad[10][5]={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int idx = 2;
string digits = "1324";
int curidx=digits[idx] - '0';
cout << curidx << endl;
}
In this case, with the inclusion on line 12, the output is 2.
// Example program
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
char keypad[10][5]={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int idx = 2;
string digits = "1324";
int curidx=digits[idx];// - '0';
cout << curidx << endl;
}
In this result, the output result is 50. What does the inclusion of - '0'
do?