| |

VerySource

 Forgot password?
 Register
Search
View: 841|Reply: 5

StrArray.Add

[Copy link]

5

Threads

17

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-11-19 10:00:01
| Show all posts |Read mode
CString str = "abcd#a#gf#eee",str1;
int i
i = str.Find("#");
str1 = str.Left(i);
StrArray.Add(str1);
The characters in str1 are abcdagfeee???
It's still separate, which means I can still take out abcd a gf eee???
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-11-19 10:15:02
| Show all posts
Are you asking about StrArray?
str1 is just sunstring
Reply

Use magic Report

5

Threads

17

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

 Author| Post time: 2020-11-19 11:15:01
| Show all posts
Well, I want to know how to put the characters in it, MSDN only says to put it at the end
It’s like an array or continuous
Mainly, after I put it in, I have to take it out for use
Reply

Use magic Report

0

Threads

20

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-11-19 11:30:01
| Show all posts
I will give you a method that can solve the problem well, but the answer that I gave you that day was not very good. Now I will give you a complete solution
CString str = "#abcd#a#gf#eee";
int Len=str.GetLength();
int Len1;
CString strTemp[10];
int i=0;
while((Len1=str.Find("#"))>=0)
{
strTemp[i]=str.Left(Len1);
str=str.Right(Len-Len1-1);
Len=str.GetLength();
AfxMessageBox(strTemp[i]);
i++;
}
AfxMessageBox(str);
At this time: strTemp[0],strTemp[1],strTemp[2],strTemp[3],str are "","abcd","a","gf","eee" respectively
Reply

Use magic Report

5

Threads

17

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

 Author| Post time: 2020-11-19 11:45:01
| Show all posts
Thank you!!!
Reply

Use magic Report

1

Threads

27

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-11-19 12:15:01
| Show all posts
i=4;
str1="abcd";
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list