02-09-2007 12:46 AM
02-09-2007 02:03 AM
When you declared your string constant array Text_Strings, CVI statically allocated as much space as needed for the given strings and no more than this. For this reason you are getting the "Array too small" error while trying to strcat someting to an element of the array, since these elements cannot be extended (neither a realloc could be attempted on them!).
Supposing your buffer variable is large enough, you can substitute your compunded statement with these two:
strcpy (buffer, Text_Strings[2]);
strcat (buffer, str);
If you actually need to strcat some data to your Text_Strings array you will need to allocate enough space at the declaration level, but be aware that ANSI C allows implementations to place string constants in a memoriy region that is protected against modification, so it cannot be guaranteed that you can always modify them.
When a pointer to a writable string must be used, it is better style and more portable to inizialize an array of characters than to establish a pointer to a string constant (Harbison & Steele, "C, a reference manual". The same can be found in other C manuals).