So, I am trying to remove a newline that is the last char in an array. The issue is, that in earlier lines I need the newline break, so when I create the array, I leave it in there, so it looks like this:
fgets(input, 100, stdin);
char *array[10];
int i = 0;
array[i] = strtok(input, " ");
while(array[i] != NULL)
array[++i] = strtok(NULL, " ");
but later on, when I run
execvp("echo", array);
It has an extra line break that I can't get rid of, like this (what it would look like from console):
(input) echo "hello"
(output) hello
(output)
*Continues code from here*
I am just wondering if anyone has any ideas on how I could remove the linebreak so, that when I run the execvp
, there would not be an extra line?