I'm trying to transfer an array from a function I've created, taking input an array of char and a short, copied below
char transl [] (char **x, short num){
char newword [] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
short num = num;
FILE * wd;
wd = fopen(argv[1], "r");
short w=0;
short arrayle=sizeof(x);
if (arrayle>9){
while((c = getchar() != '\n') && c != EOF);
}
while(((c = fgetc(wd)) != EOF)&& (num>=1)) {
if (c == ' ') {
num--;
}
if (num == 1) {
newword [w] = ((c = fgetc(wd)));
w++;
}
}
fclose(wd);
return newword;
}
I return the array of set size back into the main in the following way.
char newDay [32];
newDay = transl (engw, daynum);
I get the following error:
assignment to expression with array type
I read on Stack that I would have to pass back a pointer to the array, but wouldnt that pointer be invalid in the main without the array itself being passed back?
Anyways, extremely confused. Please advise, and thank you a lot in advance!