On 31 Mar 2007 17:03:40 -0700, sanofsans <[EMAIL PROTECTED]> wrote:

See below

> This program is supposed to pass the variable "a" to the function
> "system" which then invokes the perl script
> 5678.pl. Spritf produces the correct string which I checked with
> puts(a), but the statement system("perl a");
> does not recognize the variable "a" as a variable! When I run the
> program, it displays:
> Can't open perl script "a": No such file or directory. Since "a" is a
> variable that changes when "i" changes, I need
> to change this program, and I just do not know how! Any suggestions!
> Thank you very much!!
>
> #include <stdio.h>
>
> void main()

We use int main(), void main() is incorrect

> {
>  int i=5678;
>  char a[80];
>  sprintf(a,"%i%s",i,".pl");
>
>  system("perl a");

Variables in C don't interpolate inside literal strings like they do
in Perl. I'd put the entire command-line in the string you create (and
I'd include the .pl in the string format).

sprintf(a,"perl %i.pl",i);

system(a);

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
    If I were to divulge it, it would overturn the world."
               -- Jelaleddin Rumi

Reply via email to