I created a simple struct
in C language, for storing my data:
typedef struct
{
int n;
char *c[];
} simstr;
And, for assignment value to this struct variable, I used this code:
simstr ex =
{
5,
"ex_11",
"ex_12",
"ex_13",
"ex_14",
"ex_15"
};
To test whether ex
variable is created correctly, I run this function which I made:
void funct(simstr a)
{
int i,
n = a.n;
for (i = 0; i < n; i++)
{
printf("%s\n", a.c[i]);
}
}
funct(ex);
I compile it successfully. Unfortunately, it returns 2 lines of Θ&
; then, this program is stopped because of run-time error.
Could you show me: Why it makes error with the assignment of struct
? And how to solve them?