x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How convert TArray FString to TArray int32

Good day all. I have one question about convertation dynamic strings array to int32 array. Atoi don't take all array, only first element.

Product Version: UE 4.9
Tags:
more ▼

asked Oct 30 '15 at 02:43 AM in C++ Programming

avatar image

Kelt
24 4 5 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi Kelt,

You must iterate over string array and convert each element to int and add it to your int array.

 TArray<FString> StringArray;
 StringArray.Add("100");
 StringArray.Add("1");
 StringArray.Add("2");
 
 TArray<int32> IntArray;
 for (auto& Str : StringArray)
 {
     IntArray.Add(FCString::Atoi(*Str));
 }

Best regards, Gleb

more ▼

answered Nov 03 '15 at 04:36 PM

avatar image

Gleb.Bulgakov
1.8k 76 19 143

avatar image mrooney Nov 03 '15 at 04:44 PM

Just to add to Gleb's thing, depending on what you're doing with the array and how frequently you can always just Atoi when you actually want to use your strings as ints also.

avatar image Kelt Nov 06 '15 at 07:33 AM

Thanks for answer, Gleb. Yours faithfully, Andrew.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question