pipe stream data I/O

This is a discussion on pipe stream data I/O within the Linux Programming forums, part of the Platform Specific Boards category; I am trying to have two programs share information. The original running program streams data to a pipe and the ...

  1. #1
    vector7
    Guest

    Question pipe stream data I/O

    I am trying to have two programs share information. The original running program streams data to a pipe and the second program should read from that pipe concurrently. They are two different executables. The way I have it now is the first program executes the second program with a system call on UNIX.


    Code:
    first program
    
    
    int
    main(int argc, char *argv[])
    {
    //pipe is created
    
                  if(pipe(writepipe)==-1) {
                        perror("Pipe writepipe creation failed.\n");   //Pipe writepipe created
                  exit(1);
                       } 
                   else
                     printf("Pipeline write created.\n");
    
    
    //pipe is wrote to
    
     p1=draw_geom_buf.value[0];
     data=p1;
     write(writepipe[0],&data,sizeof(data));
    
    
    //second program is executed
    case XK_F4: //>>DDC
         printf("Displaying new window\n");
       system("./program2&");
    
    
    
    second program
    
    data is read from pipe? NO
    
    int writepipe[2];
    float input;
    
    read(writepipe[1],&input,sizeof(input));
     cout << input << endl;
    It prints out a bunch of zeros, is there anyway to fix this?

    Thanks

    DC

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Nice try with the code tags, but you need [] brackets, not {}. See here .

    I'll move this thread to the Linux forum too.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Raw I/O vs. Stream I/O
    By NuNn in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 09:32 AM
  2. Bitmasking Problem
    By mike_g in forum C++ Programming
    Replies: 13
    Last Post: 11-08-2007, 12:24 AM
  3. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 11:36 AM
  4. Search I/O file data
    By Selkie in forum C++ Programming
    Replies: 5
    Last Post: 10-17-2003, 08:35 PM
  5. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 06:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21