Here is my suggestion:
Code:
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#define MAX 10
typedef struct
{
char *word[MAX];
}Example;
void thewordsiwant(Example*,int,const char*,...);
int main()
{
int i;
Example help;
thewordsiwant(&help,2,"First","Second");
for(i=0;i<2;i++)
printf("%s\n",help.word[i]);
return 0;
}
void thewordsiwant(Example* ex,int num,const char* szFirst,...)
{
int count=0,i=1;
va_list marker;
va_start(marker,szFirst );
ex->word[0]=(char*)malloc(strlen(szFirst)+1);
strcpy(ex->word[0],szFirst);
count++;
while( count != num )
{
count++;
szFirst = va_arg( marker, char*);
ex->word[i]=(char*)malloc(strlen(szFirst)+1);
strcpy(ex->word[i],szFirst);
i++;
}
va_end( marker );
}
This is mybe wrong but it seems to works!
I wrote this with best intentions, so pleas don't give me bad reputation if you don't understand or there is some bug in the code like some people do, after all we're all learning here!