You have two fatal problems - the first is that you need to access the args[i]
member of the argument array, and the second is that you can't assign directly to the input
variable, since it's an array.
In addition:
- You should check that there is sufficient room in the
input
array;
- It's good style to explicitly return a value from
main()
;
- Whitespace is cheap, use it.
Here's what it looks like with those issues fixed:
int main(int c, char **args)
{
int i;
char input[100];
bzero(input, 100);
for(i = 1; i < c; i++)
{
if (strlen(input) + strlen(args[i]) + 2 <= 100)
{
strcat(input, args[i]);
strcat(input, " ");
}
}
puts(input);
return 0;
}
(I also included the puts()
line so that you can see what ends up in input
).