In addition, the allocation of
(void *)lr = MemPtrNew(100) ;
is excessive. it should be
lr = (InfoInterne *) MemPtrNew(sizeof(InfoInterne));
Remember, that will allocate memory for the struct only.
Each char * member of that struct will need memory
allocated separately.
--
-Richard M. Hartman
[EMAIL PROTECTED]
186,000 mi/sec: not just a good idea, it's the LAW!
Dave Lippincott wrote in message <33687@palm-dev-forum>...
>
>This is a basic C problem, not a Palm one. You have not allocated any
>memory to 'user' (or any of the other char *) the char * is just a
pointer,
>it need to point to memory. Either do it statically (char user[50]) or
>dynamically (user = (char *) MemPtrNew(StrLen(string)+1)). And don't
forget
>to add 1 byte for the terminating NULL
>
>
>
>----- Original Message -----
>From: "Fabrice Meichtry" <[EMAIL PROTECTED]>
>Newsgroups: palm-dev-forum
>To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>Sent: Wednesday, December 20, 2000 9:39 AM
>Subject: Initializing a structure
>
>
>> Hi,
>>
>> I'm new in the programmation of Palm and still have an error when I wish
>to
>> add information in on CharPtr of my structure.. Here my code
>>
>>
>>
>> typedef struct
>> {
>> char *user ;
>> char *nomClient ;
>> UInt codeClient ;
>> char *nomFournisseur ;
>> char *noTelFourn ;
>> UInt jourLiv ;
>> UInt monthLiv ;
>> UInt yearLiv ;
>> UInt limiteConf ;
>> } InfoInterne ;
>>
>>
>> UInt16 Initialize(void)
>> {
>> InfoInterne *lr ;
>>
>> (void *)lr = MemPtrNew(100) ;
>>
>> lr->codeClient = 0 ;
>> lr->jourLiv = 0 ;
>> lr->monthLiv = 0 ;
>> lr->yearLiv = 0 ;
>> lr->limiteConf = 99 ;
>>
>>
>>
>>
>>
>> StrCopy(lr->user, "Inconnu", 79) ; // the error is generate at this
>> point
>>
>> StrCopy(lr->nomClient, "Inconnu") ;
>> StrCopy(lr->nomFournisseur, "Inconnu") ;
>> StrCopy(lr->noTelFourn, "0") ;
>>
>> return 1 ;// saveRecord(infoInterneDB, &lr, sizeof(InfoInterne)) ;
>>
>>
>> thanks
>>
>> Fabrice
>>
>>
>>
>> --
>> 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/