I’m making a battleships game, so when I pass something such as “A10” into the coordinate function it needs to make column into letter and row into the number.
Coordinate(std::string coord = "A10")
{
char c = coord[0];
col = c - 16;
int r = atoi((coord.substr(1,2)).c_str());
row = r-1;
};
So in this example, passing A10 should make col = 0 (A=0,B=1,C=2) and row = 9.
The row equaling 9 seems to work but col equally 0 does not.
Are you trying to map the value of ‘A’ to zero? Remember that characters are single-byte integers,