in reply to Re: communication between C and perl
in thread communication between C and perl
#include <stdio.h> int main(void) { FILE *fp; /* char *line; updated correction */ char line[256]; if (mkfifo ("age-pipe", 0755) != 0) {printf ("Could not make this fifo\n");} else {printf ("FIFO was successfully made!\n");} fp = fopen ("age-pipe", "r"); for(;;){ fgets (line,256, fp); printf ("message: %s\n", line); } close (fp); }
#!/usr/bin/perl use strict; use warnings; open(FIFO, "> age-pipe") or die $!; select FIFO; $|=1; select STDOUT;$|=1; my $input = 'a'; while(1){ print "Enter your age:\n"; #my $input = <STDIN>; print FIFO "$input\n"; sleep(1); $input++ } close(FIFO);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: communication between C and perl
by jeanluca (Deacon) on Feb 09, 2007 at 13:01 UTC | |
by zentara (Cardinal) on Feb 09, 2007 at 16:36 UTC | |
by jeanluca (Deacon) on Feb 09, 2007 at 19:03 UTC |