Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor Shweta.Hegde's Avatar
    Join Date
    Jan 2009
    Posts
    61
    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.

  2. #2
    Registered User mvijay's Avatar
    Join Date
    Feb 2009
    Posts
    19
    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

  3. #3
    Regular Contributor rkmohanty's Avatar
    Join Date
    Dec 2007
    Location
    Banglore,India
    Posts
    156
    Quote Originally Posted by Shweta.Hegde View Post
    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.
    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[]();

  4. #4
    Regular Contributor remesh's Avatar
    Join Date
    Jun 2008
    Posts
    108
    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

  5. #5
    Registered User mahesh0919's Avatar
    Join Date
    May 2009
    Posts
    2
    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);

  6. #6
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    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.

Similar Threads

  1. Question regarding Java vs Symbian C++
    By Olnex in forum Mobile Java General
    Replies: 5
    Last Post: 2006-09-27, 23:53
  2. Replies: 1
    Last Post: 2006-09-27, 14:19
  3. Symbian and non Symbian J2ME
    By thongtom in forum Mobile Java General
    Replies: 2
    Last Post: 2005-06-28, 10:52
  4. How Can I Use TSmsUserDataSettings in Symbian 6.1?
    By ilsocio in forum Symbian C++
    Replies: 2
    Last Post: 2003-08-19, 16:39
  5. setting of Series 60 MIDP SDK for Symbian OS version 1.2 for networking
    By servigo in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2003-07-31, 07:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved