hi,
i have a string printed to by sprintf. i would like to: for every string printed, it copies the contents into the next element of a char array:
something like this (but this dosent work...
thanksCode:#include <stdio.h> #include <string.h> void addchars(char *sa[]){ int i; char buf[100]; for(i = 0; i <= 3; ++i){ sprintf(buf, "david %d\n",i); printf("%s", buf); strcpy(&sa[i],buf); } } int main() { char *sa[25]; printf ("%s\n",sa[0]); addchars(sa); //printf("%s,%s,%s,%s,%s\n",sa[0],sa[1],sa[2],sa[3],sa[4]); printf("%s",sa[0]); return 0; }


