c - What is wrong with this header file? -


i'm new c , starting learn header files. whilst using header i'm getting error saying invalid type argument of '->' (have struct dirent). don't understand means, read here second argument -> must pointer, tried add * (ent->*d_name) error unexpected token *, how can fix this?

#ifndef utilis_h_included #define utilis_h_included "utilis.h" #include <stdio.h> #include <dirent.h>  char *connect(const char *pattern) {     struct dirent ent;     char *d_name;      dir *mgt = opendir("\\\\example\\windows7apps");      while ((ent = readdir(mgt)) != pattern)     {         puts(ent->d_name);     } }  #endif 

i read here second argument -> must pointer,

that's wrong, "first" argument, or, actually, operand of -> operator should of pointer type.

in case, ent not pointer type, cannot use pointer member dereference operator ->. (you have used member dereference operator . instead).

actually, in code, ent should pointer, per return type of readdir(). better correct type of ent of struct dirent *, can make use of -> on ent.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -