Problem with comparing 2 CStrings that appear identicalSTL lower_bound not spec compliantVector won't store correct datatype (wchar_t instead of uint16_t)QtCreator: “Cannot open include file: 'windows.h'”Visual Studio 2008 Windows SDK Compiler ErrorConverting contents of a byte array to wchar_t*Most variables not displayed when debugging VC6 code in VS 2005 and 2010Starting at what version of Visual Studio is vsnprintf mostly standard-conformant?Compare MFC CString like MySQL comparesVisual Studio debug vs. release build: comparing int and float missmatchImporting cstring fails: include <cstring> error
What is a Union Word™?
Is it normal practice to screen share with a client?
Moving files accidentally to an not existing directory erases files?
High income, sudden windfall
How to optimize IN query on indexed column
How do professional electronic musicians/sound engineers combat listening fatigue?
Explanation for a joke about a three-legged dog that walks into a bar
Determine if a triangle is equilateral, isosceles, or scalene
Character Frequency in a String
How to write a sincerely religious protagonist without preaching or affirming or judging their worldview?
Invert Some Switches on a Switchboard
Film where a boy turns into a princess
Can two figures have the same area, perimeter, and same number of segments have different shape?
how to add 1 milliseconds on a datetime string?
Why did computer video outputs go from digital to analog, then back to digital?
Area of parallelogram = Area of square. Shear transform
Company requiring me to let them review research from before I was hired
Should I describe a character deeply before killing it?
Why is the return type for ftell not fpos_t?
Why do people say "I am broke" instead of "I am broken"?
How can I create a shape in Illustrator which follows a path in descending order size?
"I you already know": is this proper English?
What to do when you reach a conclusion and find out later on that someone else already did?
Protected custom settings as a parameter in an @AuraEnabled method causes error
Problem with comparing 2 CStrings that appear identical
STL lower_bound not spec compliantVector won't store correct datatype (wchar_t instead of uint16_t)QtCreator: “Cannot open include file: 'windows.h'”Visual Studio 2008 Windows SDK Compiler ErrorConverting contents of a byte array to wchar_t*Most variables not displayed when debugging VC6 code in VS 2005 and 2010Starting at what version of Visual Studio is vsnprintf mostly standard-conformant?Compare MFC CString like MySQL comparesVisual Studio debug vs. release build: comparing int and float missmatchImporting cstring fails: include <cstring> error
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
2 strings which appear to be equal, don't test as equal. I am using Microsoft Visual Studio 2008. I have added a watch for each CString, and in the watch window they appear identical. But when i try to compare them using:
a = b;
or a.compare(b);
they don't compare.
bool CDictionaryClass::CheckWord(CString word)
// get starting position for search
LPTSTR buff = word.GetBuffer(10);
wchar_t testChar = tolower(buff[0]);
int loc = int(testChar) - 97;
int end,testLength,test;
CString testWord = word.MakeLower(),dictWord;
testLength = word.GetLength();
word.ReleaseBuffer();
if(loc == 25)
end = GetNumberOfWords();
else
end = ABCPositions[loc+1];
for(int i=ABCPositions[loc]; i<end; i++)
if(dictionaryWords[i].length == testLength)
dictWord = dictionaryWords[i].word.MakeLower();
if(testWord == dictWord)
return true;
return false;
I expect testWord to equal dictWord
c++ c-strings
add a comment |
2 strings which appear to be equal, don't test as equal. I am using Microsoft Visual Studio 2008. I have added a watch for each CString, and in the watch window they appear identical. But when i try to compare them using:
a = b;
or a.compare(b);
they don't compare.
bool CDictionaryClass::CheckWord(CString word)
// get starting position for search
LPTSTR buff = word.GetBuffer(10);
wchar_t testChar = tolower(buff[0]);
int loc = int(testChar) - 97;
int end,testLength,test;
CString testWord = word.MakeLower(),dictWord;
testLength = word.GetLength();
word.ReleaseBuffer();
if(loc == 25)
end = GetNumberOfWords();
else
end = ABCPositions[loc+1];
for(int i=ABCPositions[loc]; i<end; i++)
if(dictionaryWords[i].length == testLength)
dictWord = dictionaryWords[i].word.MakeLower();
if(testWord == dictWord)
return true;
return false;
I expect testWord to equal dictWord
c++ c-strings
If you have a real c-string, you should compare the content and not the address. But I have no idea if CString is a c-string with an compare operator or not.
– Klaus
Mar 26 at 16:18
and in the watch window they appear identical. -- That is because the "watch window" does not show (or is not easy to show) control characters, invisible characters, etc. Either use the "Memory Window", where you see the actual byte/hex values of the characters, or simply write a loop to show the characters that make up each string to show what the actual characters that are making up the string. But seriously, these are the things you should have investigated before posting -- the program is not telling a lie -- the strings are not the same.
– PaulMcKenzie
Mar 26 at 16:29
add a comment |
2 strings which appear to be equal, don't test as equal. I am using Microsoft Visual Studio 2008. I have added a watch for each CString, and in the watch window they appear identical. But when i try to compare them using:
a = b;
or a.compare(b);
they don't compare.
bool CDictionaryClass::CheckWord(CString word)
// get starting position for search
LPTSTR buff = word.GetBuffer(10);
wchar_t testChar = tolower(buff[0]);
int loc = int(testChar) - 97;
int end,testLength,test;
CString testWord = word.MakeLower(),dictWord;
testLength = word.GetLength();
word.ReleaseBuffer();
if(loc == 25)
end = GetNumberOfWords();
else
end = ABCPositions[loc+1];
for(int i=ABCPositions[loc]; i<end; i++)
if(dictionaryWords[i].length == testLength)
dictWord = dictionaryWords[i].word.MakeLower();
if(testWord == dictWord)
return true;
return false;
I expect testWord to equal dictWord
c++ c-strings
2 strings which appear to be equal, don't test as equal. I am using Microsoft Visual Studio 2008. I have added a watch for each CString, and in the watch window they appear identical. But when i try to compare them using:
a = b;
or a.compare(b);
they don't compare.
bool CDictionaryClass::CheckWord(CString word)
// get starting position for search
LPTSTR buff = word.GetBuffer(10);
wchar_t testChar = tolower(buff[0]);
int loc = int(testChar) - 97;
int end,testLength,test;
CString testWord = word.MakeLower(),dictWord;
testLength = word.GetLength();
word.ReleaseBuffer();
if(loc == 25)
end = GetNumberOfWords();
else
end = ABCPositions[loc+1];
for(int i=ABCPositions[loc]; i<end; i++)
if(dictionaryWords[i].length == testLength)
dictWord = dictionaryWords[i].word.MakeLower();
if(testWord == dictWord)
return true;
return false;
I expect testWord to equal dictWord
c++ c-strings
c++ c-strings
asked Mar 26 at 16:12
BigEFrom84BigEFrom84
11 bronze badge
11 bronze badge
If you have a real c-string, you should compare the content and not the address. But I have no idea if CString is a c-string with an compare operator or not.
– Klaus
Mar 26 at 16:18
and in the watch window they appear identical. -- That is because the "watch window" does not show (or is not easy to show) control characters, invisible characters, etc. Either use the "Memory Window", where you see the actual byte/hex values of the characters, or simply write a loop to show the characters that make up each string to show what the actual characters that are making up the string. But seriously, these are the things you should have investigated before posting -- the program is not telling a lie -- the strings are not the same.
– PaulMcKenzie
Mar 26 at 16:29
add a comment |
If you have a real c-string, you should compare the content and not the address. But I have no idea if CString is a c-string with an compare operator or not.
– Klaus
Mar 26 at 16:18
and in the watch window they appear identical. -- That is because the "watch window" does not show (or is not easy to show) control characters, invisible characters, etc. Either use the "Memory Window", where you see the actual byte/hex values of the characters, or simply write a loop to show the characters that make up each string to show what the actual characters that are making up the string. But seriously, these are the things you should have investigated before posting -- the program is not telling a lie -- the strings are not the same.
– PaulMcKenzie
Mar 26 at 16:29
If you have a real c-string, you should compare the content and not the address. But I have no idea if CString is a c-string with an compare operator or not.
– Klaus
Mar 26 at 16:18
If you have a real c-string, you should compare the content and not the address. But I have no idea if CString is a c-string with an compare operator or not.
– Klaus
Mar 26 at 16:18
and in the watch window they appear identical. -- That is because the "watch window" does not show (or is not easy to show) control characters, invisible characters, etc. Either use the "Memory Window", where you see the actual byte/hex values of the characters, or simply write a loop to show the characters that make up each string to show what the actual characters that are making up the string. But seriously, these are the things you should have investigated before posting -- the program is not telling a lie -- the strings are not the same.
– PaulMcKenzie
Mar 26 at 16:29
and in the watch window they appear identical. -- That is because the "watch window" does not show (or is not easy to show) control characters, invisible characters, etc. Either use the "Memory Window", where you see the actual byte/hex values of the characters, or simply write a loop to show the characters that make up each string to show what the actual characters that are making up the string. But seriously, these are the things you should have investigated before posting -- the program is not telling a lie -- the strings are not the same.
– PaulMcKenzie
Mar 26 at 16:29
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361678%2fproblem-with-comparing-2-cstrings-that-appear-identical%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361678%2fproblem-with-comparing-2-cstrings-that-appear-identical%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you have a real c-string, you should compare the content and not the address. But I have no idea if CString is a c-string with an compare operator or not.
– Klaus
Mar 26 at 16:18
and in the watch window they appear identical. -- That is because the "watch window" does not show (or is not easy to show) control characters, invisible characters, etc. Either use the "Memory Window", where you see the actual byte/hex values of the characters, or simply write a loop to show the characters that make up each string to show what the actual characters that are making up the string. But seriously, these are the things you should have investigated before posting -- the program is not telling a lie -- the strings are not the same.
– PaulMcKenzie
Mar 26 at 16:29