Assigning unsigned char*

D

Donos

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?
 
G

Gianni Mariani

Donos said:
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).
 
D

Donos

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top