Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Software (http://www.velocityreviews.com/forums/f6-software.html)
-   -   I want to have variable parameters for sytem command in unix (http://www.velocityreviews.com/forums/t754425-i-want-to-have-variable-parameters-for-sytem-command-in-unix.html)

gorthi 09-24-2011 11:11 AM

I want to have variable parameters for sytem command in unix
 
Hi! I had typed the following code in c
main()
{
char dirname[15];
char temp[50];
printf("enter directory name: ");
scanf("%s",dirname);
sprintf(temp,"cd %s",dirname);
system((char *)temp);
}

the programmer compiles without any error using in gcc.
but when I run it and enter dirname it says can't cd and shows some junk value.
All I want is a way to pass a variable to system command ! PLS HELP REALLY URGENT!!!!!!!!!!!

gorthi 09-24-2011 11:50 AM

The code works for ls command but not for cd command.The earlier error I ahve debugged but ls works but cd command doesnt!!! I cant understand why?????


All times are GMT. The time now is 07:52 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.