I am converting from C to C++ and I did not know about reinterpret_cast.
Thank you
Greg
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
I have a MemPtr that is as a pointer to a custom structure (pdbLayout)
PDBData = static_castpdbLayout*(MemPtrNew(size));
This is also the start of my data.
I have a second pointer (Char* pOffset) that locates the end of the data.
How can I find the size of the data?
This is not the right way
If you are asking a basic 'C' question, then the following will work just fine:
unsigned long size;
size = (unsigned long)((char *)pOffset - (char *)PDBData) + 1;
Otherwise, you are asking a basic 'C++' question, so might I recommend
the following:
unsigned long size;
size
Greg wrote:
I have a MemPtr that is as a pointer to a custom structure
(pdbLayout)
PDBData = static_castpdbLayout*(MemPtrNew(size));
This is also the start of my data.
I have a second pointer (Char* pOffset) that locates the
end of the data.
How can I find the size of the data?
As
Try replacing
Char *encDate = 34857384573498573498;
with
Char encDate[] = 34857384573498573498;
Also, have you try the following before?
StrCopy(record.Date, 34857384573498573498);
On 1 Apr 2002 at 19:02, Ed wrote:
With the code below, I get the following error:
just read from
This works StrCopy(record.Date, 34857384573498573498);
This fails = StrCopy(record.Date, encDate);
It says that Application just read from memory location X which is the unused portion
of the stack. The stack is the area of RAM
used to contain function parameters and
Ed == Ed [EMAIL PROTECTED] scribbles:
Ed This works StrCopy(record.Date,
Ed 34857384573498573498); This fails =
Ed StrCopy(record.Date, encDate); It says that Application just
Ed read from memory location X which is the unused portion of the
Ed
, April 02, 2002 4:00 PM
Subject: Re: Basic C question
This works StrCopy(record.Date, 34857384573498573498);
This fails = StrCopy(record.Date, encDate);
It says that Application just read from memory location X which is the
unused portion of the stack. The stack is the area
I can see why
Char *encDate = 34857384573498573498;
might fail. Because you're assigning a pointer to some temp variable. It
depends on when that temp variable decides to go out of scope, that pointer
may no longer be valid. (Although I could be wrong. I'm not a C expert.)
However, I'm
Jake == Jake Donham [EMAIL PROTECTED] asserts:
Jake What is the real declaration of Record? Sounds like you are
Jake writing off the end of the array, and hence the stack.
Um, retract :).
Jake
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
From: Ed [EMAIL PROTECTED]
This works StrCopy(record.Date, 34857384573498573498);
This fails = StrCopy(record.Date, encDate);
It says that Application just read from memory location X which is the
unused portion of the stack. The stack is the area of RAM
Need to
Below is a sample of what I am trying to do.
I have a database with the following datatype:
Char Date[256];
In my function, I have:
Char *encDate
encDate = 34857384573498573498;
StrCopy(record.Date, encDate);
error = AddToDateDatabase(record);
What I want to do is copy encDate into the
Actually, this is a PalmOS specific programming issue, if I understand your
problem correctly. You want to copy a string into a database record. To
write to a database record, you have to use specific APIs that check to make
sure you don't write outside the record you're intending to modify. That
The I can only assume what you have left out of your example, but with these
assumptions it is correct it should be
typedef struct RecData {
Char Date[256];
} RecData;
void AddToDateDatabase(RecData* v);
void foo()
{
RecData record;
Char *encDate = 34857384573498573498;
With the code below, I get the following error:
just read from memory location 0x003CD32, which is in the unused portion of the
stack. The stack range is ... - ... and the
stack pointer is ...
This does not happen everytime. Any ideas?
Thanks,
Ed.
Borislav Kolev wrote:
The I can only
I don't know if it will make a bit of difference, but when all else fails,
start grasping at straws... I'd start by adding const to the char *
declaration:
const Char *encDate = 34857384573498573498;
Beyond that.. bobby's code below looks good to me, too.
--
Bradly J. Barton - [EMAIL
Try replace the following line
Char *encDate = 34857384573498573498;
with
Char encDate[] = 34857384573498573498;
Also, have you ever tried the following before?
StrCopy(record.Date, 34857384573498573498);
On Mon, 01 Apr 2002 19:02:31 -0800, Ed [EMAIL PROTECTED] wrote:
With the code
Todd,
Here are two solutions for PocketStudio. One if you like VB and one if you
like DELPHI g
--
Douglas Olson - President Co-founder
Pocket Technologies, Inc.
- [EMAIL PROTECTED]
- http://www.pocket-technologies.com
Develop PalmOS applications with your Delphi skills Today!
On Sun, 30 Sep 2001, Todd Cary wrote:
var
Dst: PChar;
Src: PChar;
begin
StrCopy(Src, 'Demo string');
// So far so good
// Now, how do I copy string to Dst?
// I need a substring
// This does not work: StrCopy(Dst, Src + 5);
end;
kinda helps if you allocate the memory
On Sun, 30 Sep 2001, Bradly J. Barton wrote:
StrCopy(Src, Demo string);
StrCopy(Dst, Src+5);
Personally, I like to use:
StrCopy(Dst, Src[5]);
But that's just a personal preference...
nej :) pointers.. pointers... pointers :) one of the best things about C
// az
[EMAIL
Bradley -
Many thanks! I forgot to use the @str[2] representation in Pascal
(PocketStudio for the Palm). In my code, I have a field that contains a
Time (e.g. 12:32) and I need to access the 12 and 32.
It now worksagain thanks
Todd
--
Todd Cary
Ariste Software
[EMAIL
I think only 'D' will be copied to protected space. Single quotes, and all.
-Nullife
Bradly J. Barton [EMAIL PROTECTED] wrote in message
news:63712@palm-dev-forum...
--- Todd Cary wrote:
var
Dst: PChar;
Src: PChar;
begin
StrCopy(Src, 'Demo string');
// So far so
--- Nullife [EMAIL PROTECTED] wrote:
I think only 'D' will be copied to protected space.
Single quotes, and all.
No, he's using Pascal, which uses single quotes for
strings. If he was using CodeWarrior C, 'Demo string'
would be an illegal character constant. I don't know
what gcc would
var
Dst: PChar;
Src: PChar;
begin
StrCopy(Src, 'Demo string');
// So far so good
// Now, how do I copy string to Dst?
// I need a substring
// This does not work: StrCopy(Dst, Src + 5);
end;
Todd
--
Todd Cary
Ariste Software
[EMAIL PROTECTED]
--
For information on using the
--- Todd Cary wrote:
var
Dst: PChar;
Src: PChar;
begin
StrCopy(Src, 'Demo string');
// So far so good
// Now, how do I copy string to Dst?
// I need a substring
// This does not work: StrCopy(Dst, Src + 5);
end;
This looks more like a Pascal question than a C
question,
--- Todd Cary wrote:
var
Dst: PChar;
Src: PChar;
begin
StrCopy(Src, 'Demo string');
// So far so good
// Now, how do I copy string to Dst?
// I need a substring
// This does not work: StrCopy(Dst, Src + 5);
end;
In C, you could do this:
Char Src[12];
It is actually from PocketStudio (http://www.pocket-technologies.com). It
is a new development tool for the PalmOS. It does create optimized, native
PalmOS applications (fast and small like C) and NO RUNTIME.
Just thought you would want to know!
--
Douglas Olson - President Co-founder
27 matches
Mail list logo