CString count
-
Hi All How can i ReversFind and count number of words?I have CString name="agsdfgggggg" how can count and cut these part "gggggg" from name. I mean i want to show this CString name="agsdfgggggg" to CString name="agsdf". Can any one help me.
Is "agsdfgggggg" a unique string? Is there some pattern? Does it always have the same number of characters? If you give us a bit more information we may be able to give you better advice than
CString::Left(6)
for example. -
Is "agsdfgggggg" a unique string? Is there some pattern? Does it always have the same number of characters? If you give us a bit more information we may be able to give you better advice than
CString::Left(6)
for example. -
Hi All How can i ReversFind and count number of words?I have CString name="agsdfgggggg" how can count and cut these part "gggggg" from name. I mean i want to show this CString name="agsdfgggggg" to CString name="agsdf". Can any one help me.
Wow, I have no clue what you are talking about but the answer is probably liquid nitrogen[^] Ok, serriously now. What does ReverseFind have to do with your question ? Why are you talking about words (I only see letters in your string) ? Is your string always "agsdfgggggg" and you always need to remove "gggggg" ? In which case, I don't see why you are asking the question :doh:
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
1 2 3 4 5 6 Sorry, couldn't resist... :-D
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
Hi All How can i ReversFind and count number of words?I have CString name="agsdfgggggg" how can count and cut these part "gggggg" from name. I mean i want to show this CString name="agsdfgggggg" to CString name="agsdf". Can any one help me.
Take a look at the MSDN pages for CString(). This class contains many useful functions, one of which will probably solve your problem.
-
1 2 3 4 5 6 Sorry, couldn't resist... :-D
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++I don't blame you. :-D
-
Hi All How can i ReversFind and count number of words?I have CString name="agsdfgggggg" how can count and cut these part "gggggg" from name. I mean i want to show this CString name="agsdfgggggg" to CString name="agsdf". Can any one help me.
What about
CString name = "agsdfgggggg";
int l = name.GetLength();int count=0;
while (l-- > 0)
{
if ( name[l] != 'g') break;
count++;
}if ( count > 0 )
{
name = name.Left(name.GetLength() - count);
}? [added] Sorry for the poor answer, I didn't realize that correct one is LIQUID NITROGEN. [/added] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
What about
CString name = "agsdfgggggg";
int l = name.GetLength();int count=0;
while (l-- > 0)
{
if ( name[l] != 'g') break;
count++;
}if ( count > 0 )
{
name = name.Left(name.GetLength() - count);
}? [added] Sorry for the poor answer, I didn't realize that correct one is LIQUID NITROGEN. [/added] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi All How can i ReversFind and count number of words?I have CString name="agsdfgggggg" how can count and cut these part "gggggg" from name. I mean i want to show this CString name="agsdfgggggg" to CString name="agsdf". Can any one help me.
Let me restate your requirement. You want the repeating character at the end to be removed. If this requirement is correct, here is what you can do.
name = name.TrimRight(name[name.GetLength() - 1]);
Of course, you will need error checking, which I have omitted.«_Superman_» I love work. It gives me something to do between weekends.
-
Wow, I have no clue what you are talking about but the answer is probably liquid nitrogen[^] Ok, serriously now. What does ReverseFind have to do with your question ? Why are you talking about words (I only see letters in your string) ? Is your string always "agsdfgggggg" and you always need to remove "gggggg" ? In which case, I don't see why you are asking the question :doh:
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++Cedric Moonen wrote:
Is your string always "agsdfgggggg" and you always need to remove "gggggg" ? In which case, I don't see why you are asking the question
Have you ever tried to use agsdf when it was next to gggggg? It's difficult at best.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons