There are a number of errors in your message (e.g. the strings changing from
26020060 to 23020060) so I would expect there to be errors in your code.
If EAN is declared as below, then it should really be declared as a const
because it refers to a static value. However, the way it is declared is
merely as a pointer rather than a string. You can't then do a StrNCopy to
EAN because EAN still isn't pointing to a valid string. Instead you need to
declare EAN as follows:

Char EAN[MAX_PACKET_LENGTH];

to ensure that it is large enough to accept the maximum string size. You
should also then use StrNCopy as:

StrNCopy (EAN, (CharPtr)decodeDataMsg.data, MAX_PACKET_LENGTH);

Laurence.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Sebastian Dehlinger
Sent: 09 January 2002 17:31
To: Palm Developer Forum
Subject: get a string from a pointer


Hi,

following problem:

I've got a pointer to EAN. I want to copy this number "26020060" into a
string.

StrNCopy ( EAN, (CharPtr)decodeDataMsg.data,
sizeof((CharPtr)decodeDataMsg.data));
EAN = "23020060"
*EAN = '0'
but I only get "23020060" back and not a real string like this:
EAN = "23020060"
[0] = "2"
[1] = "6"
....

I need the first 2 digits to control further functions.

EAN is declared as:
char  *EAN = { 0 };

decodeDataMsg is declared:

MESSAGE  decodeDataMsg;
/*******************************************************************
 *    Message structure used to hold decoder messages              *
 * Used by ScanGetDecodeData to return barcode type and data       *
 *******************************************************************/
typedef struct  tagMESSAGE
{
 int length; // length of the data
 int type; // contains the barcode type when the msg is DecodeData
 int status; // should be STATUS_OK
 unsigned char data[MAX_PACKET_LENGTH]; // the message data
} MESSAGE;

Thanks.

Sebastian Dehlinger




--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to