how to get the length of string in struct

Hi I am trying to get the length of string in struct as follows

struct string {
char *test
size_t len;
};

--- a couple of functions ---

int main(void)
{
struct string s;

printf("%s",s.test);
printf("%d",s.test.length());
}

when it printf("%s",s.test);, multiline string will be shown

when it printf("%d",s.test.length()), I get an error saying "request for member 'length' in something not a structure or union"

can someone help me out with this problem?

thanks in advance
Last edited on
s.test is a char*. it has no member length(). To find the length use strlen(s.test).
Or, from his structure, string.len
Topic archived. No new replies allowed.