how to get first 5 letters

Sorry just starting with this !

How would I work out letters of a word?

i.e
temp1=[this is a test]
temp2=[this another test]

I need to check the first 5 letters match, also how do I work out what each letter is ?

i.e

if temp1 letter 2 = h all good if not exit

or

if temp1 letter 6 = i all good if not exit

Many thanks

Paul


In the std::string class, the [] operator gives element access. So, if you had a string called "temp1", you could access the second element (letter) by saying "temp1[1]" - notice that the element index starts from zero, so to access the Nth element you need to give the index of n-1.
Topic archived. No new replies allowed.