If a and b are strings then surely you have to do:
Code:strcpy(a, b);
Printable View
If a and b are strings then surely you have to do:
Code:strcpy(a, b);
In general yeah, but there are simple examples that don't work like that.
char *a = "foo";
char *b = malloc(sizeof "hello world");
strcpy(b, "hello world");
strcpy(a, b);
free(a);
That's quite obviously wrong, but there is an obvious way to make a an alias of b.
a = b;
Like I said earlier, if it's the right thing to do it depends on the rest of the program code. Instead of arguing with the help he receives for the sake of a simple answer that is not going to be true always, the OP should learn the difference between pointers and arrays so he knows what's most efficient in the future.