I have a string for which I need to find out whether the position of a character is Odd or Even. Any ideas.
Printable View
I have a string for which I need to find out whether the position of a character is Odd or Even. Any ideas.
Hi Jennifer.
This is what you could do:
Lets assume that iChar is the index of the character in the string.
if the statment (iChar % 2) is true then it's odd, if it's false it's even.
if (iChar%2) ...
Regards
Jonas Pettersson
If you're using MFC, and have a CString Object,
use CString::Find () to get the index of the char, then index%2 is 0 if even, 1 if odd.
Kind regards from Germany
Moritz