| |

VerySource

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

Beginner: save string to buffer

[Copy link]

5

Threads

17

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-2-9 11:00:02
| Show all posts |Read mode
CString str1, str2, str3, str4 each have a string, and I want to save them in a buffer. How do I save them?

After saving, in another function (in the same program), I want to take out the string and assign it to each of the four CString variables. How to assign it?

Thank you so much for your answers!
Reply

Use magic Report

5

Threads

17

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

 Author| Post time: 2020-4-2 12:15:01
| Show all posts
I hope I can answer the detailed points, thank you!
Reply

Use magic Report

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-4-2 23:00:01
| Show all posts
As long as your buffer is large enough, you can use the strcat function to add strings

char buffer [1024];

strcat (buffer, str1);
strcat (buffer, str2);
strcat (buffer, str3);
strcat (buffer, str4);
Reply

Use magic Report

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-4-3 12:00:01
| Show all posts
If you want to take it out somewhere else, I built you to use the CStringArray class, so adding methods is also easy to take out!

If you want to use buffers, this may require you to define tags in the buffer to separate those number strings, which is more troublesome than
Reply

Use magic Report

5

Threads

17

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

 Author| Post time: 2020-4-3 14:45:01
| Show all posts
Thank you, how to use CStringArray specifically, can you say more specifically? Thank you very much

I can't pass it every time, I can't get it out
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-4-4 09:30:01
| Show all posts
CStringArray StrArray;
StrArray.Add (str1);
StrArray.GetAt (i)
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