i want to take the 1st argument from commandline, ie argv[1] and assign it to a char target[80]
i know im making some very stupid beginer mistakes... but just cant understand what :(
this is my code:
#include <stdio.h>
#include <string.h>
void converge(char *targ, char *src);
int main(char *argc[],char *argv[])
{
char target[80];
target=(*argv[1]);
converge(target, "This is a test of converge().");
printf("Final string: %s\n", target);
printf("%s",argv[1]);
return 0;
}
/* This function copies one string into another.
It copies characters to both the ends,
converging at the middle. */
void converge(char *targ, char *src)
{
int i, j;
printf("%s\n", targ);
for(i=0, j=strlen(src); i<=j; i++, j--) {
targ[i] = src[i];
targ[j] = src[j];
printf("%s\n", targ);
}
}
and all the problems are coming from this line target=(*argv[1]);
would be great if anyone could help on how this should work, and why this isnt working..
thanks in advance. :)
somjit