Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: getting perl and C working together in a way that makes sense

Reply
Thread Tools

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

 
 
Jorgen Grahn
Guest
Posts: n/a
 
      02-02-2013
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[i] = '\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 .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: getting perl and C working together in a way that makes sense Jens Schweikhardt C Programming 24 02-04-2013 08:12 PM
Re: getting perl and C working together in a way that makes sense Malcolm McLean C Programming 5 02-02-2013 08:31 AM
Re: getting perl and C working together in a way that makes sense Mark Bluemel C Programming 2 02-01-2013 06:58 PM
Re: getting perl and C working together in a way that makes sense Keith Thompson C Programming 0 02-01-2013 04:14 PM
Re: getting perl and C working together in a way that makes sense Johann Klammer C Programming 0 02-01-2013 08:30 AM



Advertisments