The previous post is the way to solve your problem, but... If you are programming a PIC you should not fear pointers. Just realize that once you have that 'get it' moment they won't be confusing any more. One thing to keep in mind is that C has a few notation short cuts that make things less consistant. Char buffer[20]; This one statement does several things. 1) it sets aside 20 bytes (each char is 1 byte) of memory. 2) it declares a char* named 'buffer' 3) it sets the value of the char* buffer to the beginning of the memory it set aside. Number 2 is the confusing part. It does not look like you are declaring a pointer, but in most respects buffer behaves as if it was declared "char* buffer" The next confusing thing; Variables of type char* are assumed to point to a memory location that has 0 or more byte values that correspond to ASCII characters (65 means 'A' and is OK, 200 means nothing in ASCII and is not OK) and ending in the value 0 (NULL). The 0 lets functions know how long the string is. The C compiler sets aside memory for string literals (like "dog") with one extra byte that it sets to 0 (NULL). Now strcat only works with char* (pointers to strings). There are library functions to convert standard types to there ASCII string representations. --BobG -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of John Pfaff Sent: Friday, July 20, 2001 10:48 AM To: PICLIST@MITVMA.MIT.EDU 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 that > 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 -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu