CString
-
Hi all, I am trying to trim a string and store the values in some variable. i.e I have
CString str = sample(1,2,3,4,5);
I want to store the values as
x1=1,x2=2,x3=3......so on.Any idea how can i proceed will be thankful Thanks in advance Raj
-
Hi all, I am trying to trim a string and store the values in some variable. i.e I have
CString str = sample(1,2,3,4,5);
I want to store the values as
x1=1,x2=2,x3=3......so on.Any idea how can i proceed will be thankful Thanks in advance Raj
-
Hi all, I am trying to trim a string and store the values in some variable. i.e I have
CString str = sample(1,2,3,4,5);
I want to store the values as
x1=1,x2=2,x3=3......so on.Any idea how can i proceed will be thankful Thanks in advance Raj
Dear, Firstly assign object of CString correctly.
modified on Wednesday, August 25, 2010 2:44 AM
-
Hi all, I am trying to trim a string and store the values in some variable. i.e I have
CString str = sample(1,2,3,4,5);
I want to store the values as
x1=1,x2=2,x3=3......so on.Any idea how can i proceed will be thankful Thanks in advance Raj
raju_shiva wrote:
CString str = sample(1,2,3,4,5);
The above instruction is not correct. Supposing it is:
CString str = "sample(1,2,3,4,5)"
I would use
CStringT::Tokenize
[^], have a look at the sample code provided. :)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] -
raju_shiva wrote:
CString str = sample(1,2,3,4,5);
The above instruction is not correct. Supposing it is:
CString str = "sample(1,2,3,4,5)"
I would use
CStringT::Tokenize
[^], have a look at the sample code provided. :)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]CPallini wrote:
Supposing it is: CString str = "sample(1,2,3,4,5)"
Actually i am reading it from edit box as a CString. i.e CString str = "sample(1,2,3,4,5)" I am trying with this code
CString str = "sample(1,2,3,4,5)",str1,str2;
str1 = str .Left(str .Find("("));
str2 = str .Right(str .Find("("));str.Left is working fine I am getting the result as sample But str.Right i am not getting the required result as 1,2,3,4,5). I am getting 3,4,5 What i am doing wrong Thanks Raj
-
CPallini wrote:
Supposing it is: CString str = "sample(1,2,3,4,5)"
Actually i am reading it from edit box as a CString. i.e CString str = "sample(1,2,3,4,5)" I am trying with this code
CString str = "sample(1,2,3,4,5)",str1,str2;
str1 = str .Left(str .Find("("));
str2 = str .Right(str .Find("("));str.Left is working fine I am getting the result as sample But str.Right i am not getting the required result as 1,2,3,4,5). I am getting 3,4,5 What i am doing wrong Thanks Raj
raju_shiva wrote:
str1 = str .Left(str .Find("(")); str2 = str .Right(str .Find("("));
Change to:
int pos = str.Find("(");
str1 = str.Left(pos);
str2 = str.Right( str.GetLength() - pos - 1);However, I still would use
Tokenize
for the overall task. :)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] -
Dear, Firstly assign object of CString correctly.
modified on Wednesday, August 25, 2010 2:44 AM
-
No problem, that's
CString sample(int a, int b, int c, int d, int e)
{
CString str;
str.Format("%d,%d,%d,%d,%d", a,b,c,d,e);
return str;
}CString str = sample(1,2,3,4,5);
// now extract the numbers from the string!just pure humour!
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] -
CPallini wrote:
Supposing it is: CString str = "sample(1,2,3,4,5)"
Actually i am reading it from edit box as a CString. i.e CString str = "sample(1,2,3,4,5)" I am trying with this code
CString str = "sample(1,2,3,4,5)",str1,str2;
str1 = str .Left(str .Find("("));
str2 = str .Right(str .Find("("));str.Left is working fine I am getting the result as sample But str.Right i am not getting the required result as 1,2,3,4,5). I am getting 3,4,5 What i am doing wrong Thanks Raj
I am giving example as your requirement. eg. CString str = "sample(1,2,3,4,5)",str1,str2; int curPos= 0; str1 = str.Tokenize("()",curPos); Output: str1 = 1,2,3,4,5
-
raju_shiva wrote:
str1 = str .Left(str .Find("(")); str2 = str .Right(str .Find("("));
Change to:
int pos = str.Find("(");
str1 = str.Left(pos);
str2 = str.Right( str.GetLength() - pos - 1);However, I still would use
Tokenize
for the overall task. :)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, Thank you for your reply. I have used for() loop and find to split the string. As i am not familar with Tokenize,thats why i did not used it. Thanks Raj