Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Assigning unsigned char*

Reply
Thread Tools

Assigning unsigned char*

 
 
Donos
Guest
Posts: n/a
 
      10-09-2007
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?

 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      10-09-2007
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?
>

 
Reply With Quote
 
 
 
 
Donos
Guest
Posts: n/a
 
      10-09-2007
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
no warning for assigning unsigned int to plain int V.Subramanian, India C Programming 5 10-12-2011 07:41 PM
(int) -> (unsigned) -> (int) or (unsigned) -> (int) -> (unsigned):I'll loose something? pozz C Programming 12 03-20-2011 11:32 PM
Assigning unsigned char* Donos C++ 3 10-10-2007 06:01 AM
Assigning methods to objects, and assigning onreadystatechange to an XMLHttpRequest -- an inconsistency? weston Javascript 1 09-22-2006 09:33 AM
Assigning unsigned long to unsigned long long George Marsaglia C Programming 1 07-08-2003 05:16 PM



Advertisments