[Solved] Create linux environment in C using execl and fork() [closed]
The line: a[i] = strtok(s,” “); sets a[i] to a pointer within the string, which you’re modifying and which may eventually have the temporary NUL characters (from strtok) removed. You may want to try: a[i] = strdup (strtok (s,” “)); instead. Let me explain further. Say we have the command (as it exists in memory): … Read more