> Oh, yeah, I forgot to say why just printf'ing won't work. I've got 40 > different messages to print, some have numbers in them, some display the > time, some display temperatures, some don't. It would be simple if they > were all like: > > "10:01 AM System ON" > > But some of them are also like: > > "Soup Temperature 24510F" or > "Error! You Bozo, shut off the power!" or > "Call 1-800-IMA-DUMMY for help" and so on. * > > That's why I am thinking that concatenating a string would be the right > approach. So far my efforts with STRCAT have produced nil for output. For > instance the simple code: > > DO{ > puts(*string1); > > delay_ms(1000); > > strcpy(string2, "A"); > strcat(*string1, *string2); // concatenate string1 and 'A' --- Your strcpy is OK, but the strcat won't work. strcat takes two pointers, but you have dereferenced them. It will try to use what's pointed to as a pointer (i.e. if string1[] contains "123", then strcat will try to use '1', or 0x31, as the pointer, likewise with string2; you can't be sure what you're writing or to where you are writing it). Use this and see if it helps: strcat( string1, string2 ); --- > > }WHILE(TRUE); > > which I imagined might print "A" then "AA" then "AAA" then "AAAA" etc just > prints a CR-LF over and over. Phooey. > > --Lawrence > > *Humor content of messages has been increased to add interest. Real > messages are not this funny. > > > > ----- Original Message ----- > From: "John Pfaff" > To: > Sent: Friday, July 20, 2001 9:48 AM > Subject: Re: [PIC]: Tied up with String: OR the String Cheese Incident > > > > Why not this: > > > > { > > char ampm[3] = "PM"; // This can be set to "AM" or "PM", > depending > > on time > > int Hours, Minutes; > > > > printf( "%d:%02d %s", Hours, Minutes, ampm ); > > } > > > > or even this if you really want to build a string and perhaps use it > > elsewhere as well > > > > { > > char string1[20] > > char ampm[3] = "PM"; > > int Hours, Minutes; > > > > sprintf( string1, "%d:%02d %s", Hours, Minutes, AmPm ); > > printf( string1 ); > > } > > > > > > Lawrence Lile wrote: > > > > > > I am perpetually confused by pointers in C, thus, I avoid them whenever > > > possible. (I have the same method of coping with the city bus system - > > > don't use it) > > > > > > CCS has a number of string functions, which "return pointers" whatever t > hat > > > means. What I'd like to accomplish is this: > > > > > > I want to concatenate several items into a string, then pass that string > to > > > PRINTF and squirt it out the RS232 port. > > > > > > One of the strings might be something like "10:01 AM System ON" or " 7 > 28 > > > PM System OFF" (note the blinked colon) > > > > > > Here's a stab at it, prolly fulla bugs: > > > > > > Char string1[20]; > > > . > > > . > > > . > > > > > > STRCAT(string1, Hours); // of course, Hours is an INT, not a string, > how to > > > convert to a string? > > > STRCAT(string1, ':'); // blinky colon > > > STRCAT(string1, Minutes); // minutes, also still an INT not a string ??? > > > STRCAT(string1, 'PM'); // does this work with a buncha letters? > > > etc. > > > Printf(*string1); // ?????????? > > > > > > Any suggestions are welcome > > > > > > -- Lawrence Lile > > > Sr. Project Engineer > > > Salton inc. Toastmaster Div. > > > 573-446-5661 Voice > > > 573-446-5676 Fax -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu