Connecting Tech Pros Worldwide Forums | Help | Site Map

Assigning unsigned char*

Donos
Guest
 
Posts: n/a
#1: Oct 9 '07
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?


Gianni Mariani
Guest
 
Posts: n/a
#2: Oct 9 '07

re: Assigning unsigned char*


Donos wrote:
Quote:
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).
Quote:
mVal.getValue(pbuf); // NOT GETTING VALUE HERE
}
};
>
>
>
Somehow am not able to get the "pVal" in "pbuf".
>
Why this is happening?
>
Donos
Guest
 
Posts: n/a
#3: Oct 9 '07

re: Assigning unsigned char*


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.

Closed Thread