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];
converge(target, "This is a test of converge().");
printf("Final string: %s\n", target);
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. :)

Arrays are an aggregate type, you can't simply use the assignment operator. Copying is performed with the strcpy() function. argv[1] is also a string, so *argv[1] evaluates to a single character. I suspect you meant this:

strcpy(target, argv[1]);

deceptikonfacepalm :D

thankyou so much for the superfast reply @deceptikon :) i completely forgot about strcopy!!
thank you. problem solved :) u rock :)

This question has already been answered. Start a new discussion instead.