I'm studying code C on Linux.
I have a program to execute a command line which is typed from keyboard.
This is my code
char* command;
scanf("%s", command);
execl("/bin/sh", "sh", "-c", command, NULL);
and it print out nothing.
But the weird thing is: If a do not enter the command line from keyboard anymore and I assign value for the variable, then it work like this:
char* command;
command = "ls -l";
execl("/bin/sh", "sh", "-c", command, NULL);
Can anyone show me why my code doesn't work with scanf()
Thanks a lot!