Where do you actually allocate memory to Ptext1 or Ptext2?
I see you are assigning them to static strings but you will still need to
have memory associated with the pointers in order for stringcat to work.
(StringCat doesn't reallocate memory to make the target string larger to
accommodate the new size so you may be stomping on other variables)
----- Original Message -----
From: "Matt Becker" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Friday, November 10, 2000 9:40 AM
Subject: Function, CharPtrs, and strcat
> Could someone tell me why this function wont work? I tried to init the
pointers, and it crashes. Also, without them initilized, the strcat at the
bottom crashes as well. Any ideas on how I can make this function work.
Its supposed to build a string based on
> the variable TurnIn. thanks
>
> CharPtr ReturnTurn(Word TurnIn)
> {
> CharPtr Ptext1;
> CharPtr Ptext2;
>
> Word TurnMod;
>
> //Ptext1[0]='\0';
> // Ptext2[0]='\0';
>
>
> TurnMod = TurnIn % 2;
>
> if(TurnMod == 0)
> Ptext1 = "Late ";
> if(TurnMod == 1)
> Ptext1 = "Early ";
> if((TurnIn % 24 == 0) || (TurnIn % 24 == 23))
> Ptext2 = "December";
> if((TurnIn % 24 == 1) || (TurnIn % 24 == 2))
> Ptext2 = "January";
> if((TurnIn % 24 == 3) || (TurnIn % 24 == 4))
> Ptext2 = "Febuary";
> if((TurnIn % 24 == 5) || (TurnIn % 24 == 6))
> Ptext2 = "March";
> if((TurnIn % 24 == 7) || (TurnIn % 24 == 8))
> Ptext2 = "April";
> if((TurnIn % 24 == 9) || (TurnIn % 24 == 10))
> Ptext2 = "May";
> if((TurnIn % 24 == 11) || (TurnIn % 24 == 12))
> Ptext2 = "June";
> if((TurnIn % 24 == 13) || (TurnIn % 24 == 14))
> Ptext2 = "July";
> if((TurnIn % 24 == 15) || (TurnIn % 24 == 16))
> Ptext2 = "August";
> if((TurnIn % 24 == 17) || (TurnIn % 24 == 18))
> Ptext2 = "September";
> if((TurnIn % 24 == 19) || (TurnIn % 24 == 20))
> Ptext2 = "October";
> if((TurnIn % 24 == 21) || (TurnIn % 24 == 22))
> Ptext2 = "Novemeber";
>
>
> StrCat(Ptext1,Ptext2);
>
> return(Ptext1);
> }
>
>
>
> --
> 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/