I am facing an Issue while Comparing two strings in c++.
c pointing to “dreamy” , which I have confirmed from the printf statement. Now I want to compare this with “dreamy” string but every time it is going in else part and showing not matching.
cout statement of both Str1 and Str2 also printing same output “dreamy” but the length of Str1 is showing 7 and length of Str2 is 6.
Can anybody tell me what is the problem and how to fix it.
char *c;
        c = strtok (temp,",");   
                    // Here   printf ("%s\n",c);   prints    dreamy
        while (c != NULL)
        {
            std::string Str1 = std::string(c);
            std::string Str2 = std::string("dreamy");
            cout << "Str1  " << Str1 << "Len" << Str1.length() <<endl;  //  Len = 7 showing for  c = "dreamy"
            cout << "Str2  " << Str2 << "Len" << Str2.length() <<endl;  //  Len = 6 for "dreamy"
            if(Str1.compare(Str2) == 0)
            {
                cout << "Finally Match";
                presence[1] = 1;
            }
            else
                cout << " Dont Match";
            printf ("%s\n",c);

Any help will be appreciated.
Thanks in advance!