re: Basic C Question (pointer hell)

2006-11-09 Thread Greg
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/

Basic C Question (pointer hell)

2006-11-08 Thread Greg
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

Re: Basic C Question (pointer hell)

2006-11-08 Thread Jeff Loucks
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

re: Basic C Question (pointer hell)

2006-11-08 Thread James Lin
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

Re: Basic C question

2002-04-02 Thread John Leung
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

Re: Basic C question

2002-04-02 Thread Ed
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

Re: Basic C question

2002-04-02 Thread Jake Donham
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

Re: Basic C question

2002-04-02 Thread Charu Venkatraman
, 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

Re: Basic C question

2002-04-02 Thread John Leung
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

Re: Basic C question

2002-04-02 Thread Jake Donham
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

Re: Basic C question

2002-04-02 Thread Chris Tutty
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

Basic C question

2002-04-01 Thread Edward P. Ross
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

RE: Basic C question

2002-04-01 Thread Peter Epstein
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

RE: Basic C question

2002-04-01 Thread Borislav Kolev
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;

Re: Basic C question

2002-04-01 Thread Ed
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

Re: Basic C question

2002-04-01 Thread Bradly J. Barton
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

Re: Basic C question

2002-04-01 Thread John Leung
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

Re: Basic C question

2001-10-02 Thread Douglas Olson - Pocket Technologies, Inc.
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!

Re: Basic C question

2001-10-01 Thread Aaron Ardiri
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

Re: Basic C question

2001-10-01 Thread Aaron Ardiri
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

Re: Basic C question

2001-10-01 Thread Todd Cary
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

Re: Basic C question

2001-10-01 Thread Nullife
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

Re: Basic C question

2001-10-01 Thread Joe Programmer
--- 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

Basic C question

2001-09-30 Thread Todd Cary
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

Re: Basic C question

2001-09-30 Thread Joe Programmer
--- 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,

Re: Basic C question

2001-09-30 Thread Bradly J. Barton
--- 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];

Re: Basic C question

2001-09-30 Thread Douglas Olson - Pocket Technologies, Inc.
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