I run the code below,
int main() {
char settime_parameters[13]= "042122142013";
char command[25];
sprintf(command, "date %s", settime_parameters );
printf("%s\n",command);
system("commad");
}
and I get this output:
date 042122142013
sh: 1: commad: not found
however, if I run date 042122142013
on the terminal, it works fine and changes the system time. I wonder why it does not work when I execute it through the system()
?
Thank you.
You need this:
system(command);
without the quotes.
system("commad");
should be
system(command);
without quotes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.