-1

I'm trying to make a function that takes the first and last letters of a string, divides them for the modulus and stores them in an array spot related to the modulus number. However I don't know how I would get the first and last letters of the string.

2 Answers2

2

Assuming std::string str, you can use either:

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
1

You can have the first letter of your string by just using yourString[0] and to get the last latter you can use yourString[yourString.size()-1]

EDIT

As said in the comments, assuming you're using std::string

Renan Klehm
  • 158
  • 1
  • 1
  • 9