The following is my code and I am getting some errors. Could someone help me understand these errors please?
Struct List :
struct List{ int size; int arr[]; };
Append Function :
int [] append(struct List a2, int a) { int size = a2.size + sizeof(int); int p [size]; //= (int *)malloc(size); for(int i = 0; i < size; i++ ){ p[i] = a2.arr[i]; if (i > a2.size){ p[i] = a; } } return p; }
Main Function :
int main(){ int arr[] = {12,313,13,214,23}; struct List a = {sizeof(arr)/sizeof(int), arr}; int narr [] = append(a, 50); printf("%d\n" , sizeof(arr)); }
The errors I'm getting are:
"parentheses missing before [ "
"int [] append(struct List a2, int a)"
implicit function used in "int narr [] = append(a, 50)"
没有评论:
发表评论