I'm trying to write a simple program that takes arguments and concatenates them into a single string.
It compiles fine, but when I run it, I get a segmentation fault.
Here's the code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main(int argc, char *argv[])
{
int i;
int strlen;
char str[100];
*str = 0;
for (i = 1; i <= argc; i++)
{
strcat(str,argv[i]);
}
printf("%s\n", str);
return 0;
}
I can't figure out what I'm missing.
Thanks.