Assigning unsigned char*

Discussion in 'C++' started by Donos, Oct 9, 2007.

  1. Donos

    Donos Guest

    Hello

    I have the following program,


    class CMyValues
    {
    public:
    void getValue(unsigned char* pVal)
    {
    pVal = allValues();
    }


    unsigned char* allValues()
    {
    unsigned char* a;
    -------------------
    // Some code in here
    -------------------
    return a;
    }
    };


    class CAllValues
    {
    public
    void CheckValues(CMyValues& mVal)
    {
    unsigned char pbuf[512];
    mVal.getValue(pbuf); // NOT GETTING VALUE HERE
    }
    };



    Somehow am not able to get the "pVal" in "pbuf".

    Why this is happening?
     
    Donos, Oct 9, 2007
    #1
    1. Advertising

  2. Donos wrote:
    > Hello
    >
    > I have the following program,
    >
    >
    > class CMyValues
    > {
    > public:
    > void getValue(unsigned char* pVal)
    > {
    > pVal = allValues();
    > }
    >
    >
    > unsigned char* allValues()
    > {
    > unsigned char* a;
    > -------------------
    > // Some code in here
    > -------------------
    > return a;
    > }
    > };
    >
    >
    > class CAllValues
    > {
    > public
    > void CheckValues(CMyValues& mVal)
    > {
    > unsigned char pbuf[512];


    pbuf is an array - no assignment operator will work here. You need to
    do an element by element copy or use a std::vector (much better).

    > mVal.getValue(pbuf); // NOT GETTING VALUE HERE
    > }
    > };
    >
    >
    >
    > Somehow am not able to get the "pVal" in "pbuf".
    >
    > Why this is happening?
    >
     
    Gianni Mariani, Oct 9, 2007
    #2
    1. Advertising

  3. Donos

    Donos Guest

    I tried changing "pbuf" to a pointer, but still it doesn't work.

    Where should i do the std::vector? In which class?
    Becoz i get the values correctly in the CMyValues class, but somehow
    the value of "pValue" is not correctly transfered to CAllValues class.
     
    Donos, Oct 9, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    683
    Eric Sosman
    Jul 8, 2003
  2. Steffen Fiksdal

    void*, char*, unsigned char*, signed char*

    Steffen Fiksdal, May 8, 2005, in forum: C Programming
    Replies:
    1
    Views:
    589
    Jack Klein
    May 9, 2005
  3. Ioannis Vranos
    Replies:
    11
    Views:
    762
    Ioannis Vranos
    Mar 28, 2008
  4. Ioannis Vranos

    Padding bits and char, unsigned char, signed char

    Ioannis Vranos, Mar 28, 2008, in forum: C Programming
    Replies:
    6
    Views:
    614
    Ben Bacarisse
    Mar 29, 2008
  5. Alex Vinokur
    Replies:
    9
    Views:
    798
    James Kanze
    Oct 13, 2008
Loading...

Share This Page