×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    39

    byte array and array object!!

    Hi all,
    I am trying to convert java code into symbian but i am not able to convert this part of code.
    can anyone tel me How to create byte array object? and pass those array to an other array object?
    public static final byte cw_bArray = 0x01;
    public static final byte cw_string = 0x02;

    byte[] arr1=new byte[]{0x01};
    byte[] arr2=new byte[]{0x02};
    byte[] arr3=new byte[]{0x03};
    byte[] code_ward_arr=new byte[]{cw_bArray,cw_string,cw_bArray};

    method:
    mountLVParams(null,new Object[]{arr1,arr2,arr3}, code_ward_arr);
    Thanks in advance.
    Last edited by divi11; 2012-05-23 at 06:19.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: byte array and array object!!

    http://www.cplusplus.com/doc/tutorial%20/variables/ - char is the 8-bit type, you can try signed if you want it to resemble Java more.
    http://www.cplusplus.com/doc/tutorial%20%20/arrays/ - there are array initializers too, however note that they probably have to be const. So for creating a non-const array, you will have to new[] one and copy the elements.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    39

    Re: byte array and array object!!

    Thank you wizard_hu_.

    is this correct??
    static signed char cw_bArray = 0x01;
    static signed char cw_string = 0x02;

    signed char a1 = {0x01};
    signed char a2 = {0x02};
    signed char a3 = {0x03};

    signed char b [] = {a1,a2,a3};
    and
    as you suggested i tried to new[] like this but getting illigal initiallization
    char bb [] = new char(a1);
    Last edited by divi11; 2012-05-22 at 12:08.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: byte array and array object!!

    Quote Originally Posted by divi11 View Post
    is this correct??
    'const' might be a good idea for 'final'
    as you suggested i tried to new[] like this but getting illigal initiallization
    char bb [] = new char(a1);
    I do not see the new[]. How about
    Code:
    char *bb=new char[a1];
    ?

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    39

    Re: byte array and array object!!

    its compiling without error but if i see the value of bb in debug mode it's -91 and bb = ¥¥¥¥Ì\r

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: byte array and array object!!

    It is probably not what you think. Just like in "new byte[5]" Java, "new char[5]" simply allocates a new array for 5 elements. If you want to have default elements in there, you have to copy them. Also note that C/C++ arrays are not bound, so you can not get their length, it has to be tracked separately.

  7. #7
    Registered User
    Join Date
    Nov 2011
    Posts
    39

    Re: byte array and array object!!

    signed char bbb[] = {a1,a2,a3};
    char *bb=new char[2];
    bb[0] = a1;
    bb[1] = a2;
    bb[2] = a3;

    this is working and how to pass bb?
    LOCAL_C void mountLVParams(signed char initData, char obj[], signed char codeWord)
    {

    }
    LOCAL_C void MainL()
    {
    signed char a1 = {0x01};
    signed char a2 = {0x02};
    signed char a3 = {0x03};

    // char code_ward_arr [] = new char();
    signed char code_ward_arr[] = {cw_bArray,cw_bArray,cw_bArray};

    signed char bbb[] = {a1,a2,a3};
    char *bb=new char[2];
    bb[0] = a1;
    bb[1] = a2;
    bb[2] = a3;

    mountLVParams(NULL, bb[] , code_ward_arr);
    }
    getting Expression Syntax Error.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: byte array and array object!!

    Quote Originally Posted by divi11 View Post
    signed char bbb[] = {a1,a2,a3};
    char *bb=new char[2];
    bb[0] = a1;
    bb[1] = a2;
    bb[2] = a3;
    It should be new char[3].
    this is working and how to pass bb?

    getting Expression Syntax Error.
    for the bb part, it should be mountLVParams(NULL, bb , code_ward_arr), without []. You would not write them in Java code either. However code_ward_arr is not a "signed char codeWord", so something is still wrong.

Similar Threads

  1. Converting image object into byte array
    By kamalinfo2k2@yahoo.com in forum Mobile Java General
    Replies: 7
    Last Post: 2011-02-26, 10:57
  2. How to get byte array of Image object.
    By swap842 in forum Mobile Java General
    Replies: 6
    Last Post: 2010-06-23, 18:35
  3. can we publish an object as byte array
    By mearunsingh in forum Symbian
    Replies: 2
    Last Post: 2008-05-07, 09:02
  4. Byte Array
    By fuhrer in forum Symbian
    Replies: 4
    Last Post: 2007-10-19, 11:01
  5. Reading from Image Object to a Byte Array
    By Ghouse in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-06-13, 18:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×