The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-18-2008
joey joey is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 15
little program error.

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

Code:
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