You're probably missing some RAM.
We're missing your code.
My code uses plenty of strings (it generates a web page when it gets a GET) - the 'constant' strings are held in flashmem. I do a check on the 'spare' ram on startup - and for the moment it's fine.
As for the code, do you mean the original? I didn't want to post 1600 lines of code - anyway, in trying to figure out what was going on, I boiled it all down to the example given - which seems to be acting oddly.
The project is monitoring 7 sht71 temp/humidity sensors and presenting the readings as a web page. The sensors are named as per their locations and I initialise the location array as
char* loc[nSHT] = {" NC ", " NC ", ... and so on (NC = Not Connected)
I have a config file which indicates their actual location (Shed, Atelier, Tree, etc.) and I replace the 'NC' locations with the actual location in setup (I use a config file, because I don't want users messing with the core code - setup does all kinds of integrity checks to make sure the configurer hasn't done something daft).
My problems started then. I discovered that the array 'loc' (well, the items pointed to) had all taken the last value 'overwritten' with strcpy. In fact after posting this, I've changed the initialisation of 'loc' to ....
char* loc[] = {" NC1", " NC2", and so on ...
.. and it works fine.
It looks as though the declaration of 'loc' - where all the initialisers are identical - generates a single string and makes all the pointer elements point to this same (single) string - so replacing one replaces all.
The last case works because an assignment (as opposed to a strcpy) generates a new string, pointed to by loc[0] (or whichever)
@pYro_65
Thanks for the advice. In fact I'm sure you're correct about the initialiser - sadly either way has no effect. I've also tried all possible combinations of * and & (clutching at straws) to no avail.
As mentioned above, it seems to me that ...
a) Defining a char* array where all initialisations strings are identical results in an array of pointers all pointing to the same string. Thus changing any one results in them all (apparently) changing.
b) Doing the above with all initialisers different, results in separate and distinct strings.
c) The fact that loc[0]="newstr" gives the result it does, must mean that a new string is created and pointer[0] now points to that. loc[1] and loc[2] still point to the same string.
I hadn't realised strings were so tricky.