I wonder how the previous code compiled : the argument passed to the function fillarray was of the wrong type. The operator = does not copy strings in C; you have to use the function strcpy.
It is a good idea to include the appropriate headers.
Code:
#include <stdio.h>
#include <string.h>
struct myStruct {
char name[40];
int age;
};
void fillArray(struct myStruct *);
int main(void){
struct myStruct myStructArray[10];
fillArray(myStructArray);
printf("%s", myStructArray[2].name);
return 0;
}
void fillArray(struct myStruct * workwithStruct){
strcpy( (workwithStruct+2)->name,"JOHN");
return;
}