I am using this code to extract a password protected rar file. I am using the system function to invoke the rar command. If I use the password in the system command, It works. But as tries to pass the password as parameter, It don't. eg if in this code if I use password pwd, it gives the error "pwd is not recognised as internal or external command,operable programe or batch file." But if I change the code and make it "system("rar e -ppwd wingen.rar")" , It works. Can anybody explain me , what mistake I am doing? Thanks in advance.
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char **argv)
{
char pword[20];
printf("enter the pword : ");
gets(pword);
system(("rar e -p%s wingen.rar",pword));
getchar();
return 0;
}