I've done this with your function and is working just fine:
Code:
#include <stdio.h>
void printtofile(char **wrdhold, char *out)
{
printf("%s\n", wrdhold[5]);
FILE *f_out=fopen(out, "w");
if(f_out==NULL) {
printf("Error: can't create file for writing.\n");
}
fprintf(f_out, "%s", wrdhold[0]);
fclose(f_out);
}
int main()
{
char *wrdhold[10], *out = "text.txt";
wrdhold[0] = "ana";
wrdhold[5] = "ddsd";
printtofile(wrdhold, out);
return 0;
}
First of all wrdhold is a pointer to a pointer to a char... maybe this is your pb.. maybe your not using it like that or maybe u don't initialized your wrdhold so that your passing garbage data.