little program error.

I am trying to work this little program, its not working..

int main()

{
               FILE *fp;
               char *args[40];
               pid_t child, exited_pid;
               int status = 0;
               *args[0] = "less";
               fp = popen("ls", "r");
               child = fork();
               if(child == 0)
              {
                      dup2(fp->fd, 0);
                      if(execvp(args[0], args) == -1)
                             {
                                printf("error");
                               exit(EXIT_FAILURE);
                              }

                wait(&status);
                wait(&status);
}

I got error.
Warning: assignment makes integer from pointer without a cast
Error: 'FILE' has no member named 'fd'
Error: expected declaration or statement at end of input.

My whole goal of the program is to execute ls, and read from that program & store it in the buffer. Then my second program (argss[0]) reads the input coming from there and uses it...

help plz:)

C: FILE Structure !, FILE structure in C

typedef struct  {
       int             level;      /* fill/empty level of buffer */
       unsigned        flags;      /* File status flags          */
       char            fd;         /* File descriptor            */
       unsigned char   hold;       /* Ungetc char if no buffer   */
       int             bsize;      /* Buffer size                */
  unsigned char   *buffer;    /* Data transfer buffer       */
  unsigned char   *curp;      /* Current active pointer     */
       unsigned        istemp;     /* Temporary file indicator   */
       short           token;      /* Used for validity checking */
}       FILE;   

How come "FILE" has no member named fd

FILE is opaque -- you're not supposed to mess with what's inside, because it might be different everywhere you go. It's like a system call, you aren't supposed to ask the kernel what's inside its file tables. Technically you can get the fd with fileno() but since any actions on fp after you mess with its raw file descriptor may be unpredictable, I'd suggest making a pipe(), forking, and redirecting through the pipe instead. That's how popen works anyhow.

k thx

This is wrrong too:

*args[0] = "less"

You have declared args to be an array of pointers to char, and "less" is a pointer to char, so you need

args[0] = "less"