Re: getting perl and C working together in a way that makes sense

Discussion in 'C Programming' started by Jorgen Grahn, Feb 2, 2013.

  1. Jorgen Grahn

    Jorgen Grahn Guest

    On Fri, 2013-02-01, Cal Dershowitz wrote:
    > $ cat perl1.c
    >
    > #include <stdio.h>
    >
    > int
    > main (int argc, char *argv[])
    > {
    >
    > // write perl file to a string
    > char text[1000];
    > FILE *fp = fopen ("capture3.pl", "r");
    > int i = 0;
    > while (feof (fp))
    > text[i++] = fgetc (fp);
    > text = '\0';
    >
    > // output perl source to file
    > FILE *fp;
    > char *perlfile = "/tmp/doppelgaenger.pl"; // edit
    >
    > // add error checking to open/flose/system


    This is a type of mistake which annoys me. Your other comments are
    statements of intent, and then the lines below do it. This one is
    formulated in exactly the same way, but carries the opposite meaning:
    the lines below /omit/ all the vital error handling.

    > fp = fopen (perlfile, "w");
    > fprintf (fp, "%s\n", perlsource);
    > fclose (fp);
    >
    > char cmd[100];
    > sprintf (cmd, "perl %s %s", perlfile, argv[1]);
    > system (cmd);
    > }


    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
    Jorgen Grahn, Feb 2, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johann Klammer
    Replies:
    0
    Views:
    206
    Johann Klammer
    Feb 1, 2013
  2. Malcolm McLean
    Replies:
    5
    Views:
    226
    Bart van Ingen Schenau
    Feb 2, 2013
  3. Mark Bluemel
    Replies:
    2
    Views:
    206
    James Kuyper
    Feb 1, 2013
  4. Keith Thompson
    Replies:
    0
    Views:
    199
    Keith Thompson
    Feb 1, 2013
  5. Jens Schweikhardt
    Replies:
    24
    Views:
    467
    Jorgen Grahn
    Feb 4, 2013
Loading...

Share This Page