You have misplaced your parentheses.
The statement you coded
if (strncmp(first.data(), second.data(), second.length() == 0))
has the arguments to strncmp parsed as
arg 1 = first.data()
arg 2 = second.data()
arg 3 = second.length() == 0
Since second.length() is not zero, this argument is evaluated to false before calling strncmp. Since there is no other text inside the if statement, the statement is process as
if ( strncmp(...) )
and since the first two arguments are equal strncmp returns 0 which the if streats as false.
The if statement should read
if (strncmp(first.data(), second.data(), second.length()) == 0)
so that arg3 becomes second.length() and the value returned by strncmp is then compared to 0.
The same problem exists in the _wcsnicmp if statement.