CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 1999
    Location
    Colorado, USA
    Posts
    6

    String Manipulation

    I have a string for which I need to find out whether the position of a character is Odd or Even. Any ideas.


  2. #2
    Join Date
    Jun 1999
    Location
    Sweden
    Posts
    38

    Re: String Manipulation

    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

  3. #3
    Join Date
    Jun 1999
    Posts
    1

    Re: String Manipulation

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured