s@freddix
I've had the same problem recently, trying to convert my palmos databook database to lipidclock reminder format. Luckily, I just do:
char *string;
if((string=malloc(strlen("string to enter"))!=0)
{
sprintf(string, "%s", "string to enter");
}
else
{
printf("Memory allocation error!\a\n");
}
To swap different string, I guess you need to use the (previously mentioned) realloc() command, eg..
char *string1 = "first string";
char *string2 = "second string";
char *changestring;
if((changestring=malloc(strlen(string1))!=0)
{
sprintf(changestring, "%s", string1);
};
if((changestring=realloc(strlen(string2))!=0)
{
sprintf(changestring, "%s", string2);
};
Also, I prefer to use sprintf() instead of strcpy, the additional formatting options are very useful. (personal preference though). Sprintf uses the same args as printf, the pointer before the format string is where you put the array name)
I've made extensive use of a couple of websites that have been quite life-savers for looking up stuff, too.
cplusplus.com, though you have to be careful with this one if you're using straight C, and not C++. Plus, the language can be kinda thick at times, though it has some good example code.
C Programming Reference is one I found the other day, but it looks like beginner-level example code. Also DOS/X86 based afaik.
C programming.com seems useful for beginner level stuff, too.
I've been getting used to the memory allocation probs myself, having trashed my system memory to the point of requiring a cold reset. (I'm using BlizKick to set up a custom 3.9+goodies kickstart, which isn't "locked", resulting in a restart and a lovely red screen when it gets trashed. Using RTG means I need to flip the VGA switch to even see that...)
EDIT: If you go to those links via Ibrowse, you may want to disable javascript to speed things up a bit. (I have them in the URL prefs w/ Javascript disabled)