Sorry Viraj, now I see:

This is what needed:

typedef struct {
        Char formName[11];      // Smth sufficient
}....

After that using StrCopy is up to you.
Honestly I don't see a need for a structure
For further extensions ?

Michael


-----Original Message-----
From: Michael Glickman [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 27 November 2001 2:33 PM
To: Palm Developer Forum
Subject: RE: trouble with struct


Honesty, I don't understand what Viraj is talking about,
but here is the solution:

Replace StrCopy by MemMove:
 
     MemMove(myform->formName, buffer, sizeof(myFormStruct ));

StrCopy is for null-terinated strings, not for bunary structures.

Michael



-----Original Message-----
From: Viraj Chatterjee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 21 November 2001 10:25 PM
To: Palm Developer Forum
Subject: Re: trouble with struct


>     StrCopy(myform->formName, buffer);
where's the memory for formName ??

myform->formName = (Char*)MemPtrNew(MAX_SIZE * sizeof(Char));
StrCopy(............

Frankly, even the statements before the StrCopy could land you in trouble,
since you're assigning a constant string to a ptr that isn't constant...


Please go through a good book on C programming first.

-vc



----- Original Message -----
From: "J�lio F�bio de O. Chagas" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Wednesday, November 21, 2001 4:36 PM
Subject: trouble with struct


> What is wrong with the code bellow ?
>
> ---definitios.h------- X ----------------------------
> typedef struct {
> Char * formName;
> } myFormStruct;
>
> typedef myFormStruct *myFormStructPtr;
> ---main.c------------- X ----------------------------
> void myFunction()
> {
>     myFormStructPtr myform;
>     Char *buffer;
>
>     myform = (myFormStructPtr) MemPtrNew(sizeof(myFormStruct ));
>     buffer = "FormNumberOne";
>     StrCopy(myform->formName, buffer);
>     ...
>     ...
> }
>
>
>
> --
> 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/

-- 
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