Hi,
I'm trying to assign different values to each element in a string array with no success.
The values come from parsing a .ini file using the strtext() function.
As strtext() output is a temporary array, I copy the temporary array to a char array with the intention to make the value permanent.
And then assign its value to the element array.
But at the end, all elements in the array end up with the same value. The last temporary string.

My question is how to permanently assign a value to a string array element that comes from a temporary array.
It seems simple, but I'm messing up my head.

This is the code:

#define MAXGROUPS 5
string NamesGroups[MAXGROUPS];
char s1[100];
char s2[100];

function main()
{
string Ini_File = "...file.ini";
string ini_content = file_content(Ini_File);

for(i=0; i<MAXGROUPS; i++)
{
strcpy(s1,strf("NameGroup%02i",i));
strcpy(s2,strtext(ini_content,s1,""));
NamesGroups[i] = s2;
printf("\n************** %s = %s",s1,NamesGroups[i]);
}

// check the result
for(i=0; i<MAXGROUPS; i++)
printf("\n- NameGroup%02i = %s",i,NamesGroups[i]);
}

This is the output:

s1 = NameGroup00
s2 = StocksLong
************** NameGroup00 = StocksLong
s1 = NameGroup01
s2 = StocksShort
************** NameGroup01 = StocksShort
s1 = NameGroup02
s2 = BDRs
************** NameGroup02 = BDRs
s1 = NameGroup03
s2 = RV_ETFs
************** NameGroup03 = RV_ETFs
s1 = NameGroup04
s2 = FIIs
************** NameGroup04 = FIIs
- NameGroup00 = FIIs
- NameGroup01 = FIIs
- NameGroup02 = FIIs
- NameGroup03 = FIIs
- NameGroup04 = FIIs