Home > Back-end >  Read INI file, separated with a comma, in the array
Read INI file, separated with a comma, in the array

Time:10-01

For example: 22,33,44,55,66...
Write a line of string, how can I make a copy of every number to each element of an array china-arab
Is
String [] array=new string (comma interval number (the number of commas + 1)]
Array [0]=22
Array [1]=33
Array [2]=44
Array [3]=55
Array [4]=66

To the c + +,
Great god put a code,

CodePudding user response:

Separated by Stringlist

CodePudding user response:

If the points are two digits is simple,
Array [I]=ss. The SubString (I * 2, (I + 1) * 2);

CodePudding user response:

Figures are not fixed digits, I'll use silly way to verify success
 
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
String ss="212313,44,55,66";
The String Array [10].
Int Index=0;
Char ch;
String temp="";
Char * SCH=ss. C_str ();

for(int i=0; I{
If (SCH [I]! )=', '
Temp +=String (SCH) [I];
The else
{
Array [Index++]=temp;
Temp="";
}
}
Edit1 - & gt; Text=Array [0].
Edit2 - & gt; Text=Array [1].
Edit3 - & gt; Text=Array [2].
}

CodePudding user response:

To deal with the most suitable with TStringList
 String strText="22,33,44,55,66"; 

TStringList * LST=new TStringList;

LST - & gt;=', 'Delimiter.
LST - & gt; DelimitedText=strText;

//a total divided into Count period of
ShowMessage (LST - & gt; The Count);
//the value of the third member
ShowMessage (LST - & gt; Strings [2]);

The delete LST.
  • Related