CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: CString

  1. #1
    Guest

    CString

    Sir,
    Lets suppose
    CString temp="hellojshduahelloAIIHELLO";
    Can I determine number of occurances of "hello" in the above "temp", how?.
    Sajjad


  2. #2
    Join Date
    Aug 1999
    Posts
    70

    Re: CString

    CString temp="hellojshduahelloAIIHELLO";
    CString junk = temp;
    junk.MakeUpper();
    int index = junk.Find("HELLO");
    int count = 0;
    while(index >= 0)
    {
    count++;
    junk = junk.Right(junk.GetLength() - (index + 5));
    index = junk.Find("HELLO");
    }
    //count is the number of occurrences, case insensituve



  3. #3
    Guest

    Re: CString

    Thanks for your response, your solution works very fine.
    Sir I have a simple problem left.
    What I am using is to search a string "%%Pages:" in a file. I am using "fread()" to get the file contents and put the wole file in the "CString temp". Now
    what follows after "%%Pages:" is an integer i.e "%%Pages: 6". Can we get this integer from the temp.
    Sincerely
    sajjad


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