Pointers. Pointers are variables that hold the address of an object in memory, rather than the object itself. Pointers are an efficient way of handling large objects. Pointers are how you usually deal with dynamically allocated objects (however, this was my first exposure to pointers (in PL/1 and Pascal), and it took be AGES to "get it", because so few of my programs actually used dynamically allocated objects.) In C, pointers are important and more common because C does not have any native "string" data type, nor any defined operations for strings (which follows, eh?) (However, the compiler has a string CONSTANT type. Go figure.) Pointers are a common and preferred way to deal with text strings in C. Now, it's not clear whether pointers make sense (even for strings) on a PIC processor. The (low and midrange) PICs don't really have an architecture that supports pointers very well (at all?) (arguably, the PIC does not have 'memory' of the sort that pointers normally point to at all, just "registers.") This means that the compiler has to do some fancy footwork to implement pointers (or even to implement strings, come to think of it.) Whether it will do a good job is something you have to learn by looking at the code that it produces when you try. (or by asking people who have done so.) >> char strings[4][9] = {"Pancakes","Eggs","Bacon","Buscuits"}; >> >> The problem with this method is there are nine bytes of storage >> allocated for "Eggs" and "Bacon", but only 5 and 6 bytes, repectivly, >> of those entries are used and there is no way of recovering the lost bytes. > > const char *strings[] = {"Pancakes","Eggs","Bacon","Biscuits"}; > > No wasted ROM that way. Um. The first case "wastes" several bytes of each string that is shorter than the max. The second case "wastes" space to store the pointers to the strings. Which is worse will depend on circumstances. I've been known to do things like: char strings[] = "Pancakes\0Eggs\0Bacon\0Buscuits\0Other\0"; #define STRING_PAN 0 #define STRING_EGG 1 #define STRING_BAC 2 #define STRING_BUS 3 /* * print the Nth (stringID) null-delimitted substring of the big string. * Note that the end of the big sting should have a double null. */ void printstring (int stringID) { int i=0; /* * Find the (1st character of) the Nth string. */ while (stringID > 0) { while (strings[i] != 0) { /* Look for separator */ i++; /* Next character */ } i++; /* Skip the separator */ if (strings[i] == 0) return; /* End of big string is an error! */ stringID--; /* next substring */ } /* * Should be pointing to first character of the desired string. * Now output that string... */ while (strings[i] != 0) { putchar(strings[i]); i++; } /* * Here, we could purchar CRLF if we wanted */ } (This code has not been compiled or tested!!) This sort of thing can save quite a bit of string space, depending on assorted unknowns (number of strings, how they compile down, etc.) (at the expense of CPU time, of course. Since strings tend to be human UI things, and PICs tend to be pretty zippy compared to people, you probably have the CPU time to spare.) It looks like a lot of code, but a fair number of those while loops ought to turn out to be just a couple of PIC instructions each, and there's likely to be a pretty good match up with the way constants might actually be stored on a PIC (ie as a series of RETLW instructions.) In the worst case, you can write printstring() in assembler... You can (maybe) do tricks with C syntax that may or may not help the compiler, like while (putchar(strings[i++])) ; but ... extreme care is advised. (hint: this short version is not quite the same as the longer form further up the page. Also, putchar might be a macro, and it can be a bad idea to use ++ and similar on macro arguments.) BillW -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics