I have these 2 structs:
#define M 100
#define N 100
typedef struct xml_Element {
pData_Element data;
pAttr_Element attr_arr[M];
struct xml_Element *parent;
struct xml_Element *children[N];
int depth;
int num_of_children;
int num_of_attr;
} Xml_Element,*pXml_Element;
typedef struct attrElem {
char *attrName;
char *attrValue;
}Attr_Element,*pAttr_Element;
and I wrote this function:
pAttr_Element getXmlAttrArray(pXml_Element node) {
return node->attr_arr;
}
I have a couple of questions:
- Why is it illegal? If I change the function to:
{pAttr_Element* getXmlAttr....}
it works but I don't understand why.
Inside my struct I have a pointer to an array, where every cell is a pointer of type pAttr_Element right? Or it's not a pointer to an array? I'm lost :(
Why is it not working if I change the function to:
Attr_Element getXmlAttrArray(..)
? When I return:node->attr_arr
what is the return type?How can I change the struct in order to return a pointer to an array Of pAttr_elements?
Thank you!