-
Array in symbian
Hi all,
I want to store some data like "hello", "hello1","hello2","hello3" in an array. Such that "hello" is the first element of the array, "hello1" is the second element and so on. I want to retrieve these data in a for loop just like we do in c++... something like
for(int i =0; i<array.length;i++)
{
cout << array[i]<< endl;
}
actually i want to display the data inside the array inside a rectangle using draw text. How can i initialize the array and retrieve the elements from it.
-
Re: Array in symbian
Hi,
You can use CDesCArray to store descriptor type data. If you want to insert text items into it, can use AppendL() method.
For getting the no. of elements in the array, can use Count() method.
For traversing through the array, use At() or Operator[]() methods passing the index.
Refer the SDK on CDesCArray for more details.
Cheers,
Vijay M
-
Re: Array in symbian
[QUOTE=Shweta.Hegde;538467]Hi all,
I want to store some data like "hello", "hello1","hello2","hello3" in an array. Such that "hello" is the first element of the array, "hello1" is the second element and so on. I want to retrieve these data in a for loop just like we do in c++... something like
for(int i =0; i<array.length;i++)
{
cout << array[i]<< endl;
}
actually i want to display the data inside the array inside a rectangle using draw text. How can i initialize the array and retrieve the elements from it.[/QUOTE]
Hi, You can use
CDesCArrayFlat;
create a pointer object allocate memory through new operator;
And insert item into array through AppendL() method;
And retrieve the item through ->operator[]();
-
Re: Array in symbian
Hi,
You can use CDesCArrayFlat.
see this code:-
CDesCArrayFlat* array=new (ELeave)CDesC16ArrayFlat(5);
TBuf<20> data1;
TBuf<20> data2;
TBuf<20> data3;
data1=_L("hello");
data2=_L("hello1");
data3=_L("hello2");
array->AppendL(data1);
array->AppendL(data2);
array->AppendL(data3);
you can retrieve elements by giving " (*array)[i] " in a for loop.
or you can retrieve the elements like this :-
TBuf<20> retrve_data1;
retrve_data1=(*array)[0] ;//for first element
remesh
-
Re: Array in symbian
CDesCArrayFlat* array=new (ELeave)CDesC16ArrayFlat(5);
TBuf<20> data1;
TBuf<20> data2;
TBuf<20> data3;
data1=_L("hello");
data2=_L("hello1");
data3=_L("hello2");
array->AppendL(data1);
array->AppendL(data2);
array->AppendL(data3);
access each element by
&array->operator [](0);
&array->operator [](1);
&array->operator [](2);
-
Re: Array in symbian
Note that this thread has happened a bit earlier (3+ months ago).
Anyway, although the x->operator[](y) construct works, some may consider (*x)[y] more readable.