--- sanofsans <[EMAIL PROTECTED]> wrote:
> Hi folks!
>
> 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()
> {
> int i=5678;
> char a[80];
> sprintf(a,"%i%s",i,".pl");
>
> system("perl a");
>
> /*puts(a); Display message correctly though*/
> return;
>
> }
>
>
Since "a" is inside the quotes its not a variable but
part of the string. See below.
void main()
{
int i=5678;
char a[80];
char b[80] = "perl ";
sprintf(a,"% i%s",i,". pl");
strcat(b, a);
system(b);
return
}
Mickey M.
Construction Partner Inc.
http://www.constructionpartner.com
____________________________________________________________________________________
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/