Are they any difference if i use strcpy()
fuction and the assignment operator ?
char word[][40],*first;
Below is the 2 example.
*first=word[0];
strcpy(first,&word[0]);
strcpy
performs deep copy. It copies data contained in memory at address, which is equal to value of pointer, to memory at address, which is equal to second pointer.
Assignment simply assigns second pointer value of the first pointer.
Here is a small figure for you:
A -> "some data "
B -> "some other data "
After assignment:
A -> "some data "
/
/
B "some other data "
After strcpy:
A -> "some data "
B -> "some data "
Mind the fact that memory for strcpy
to copy to must be allocated beforehand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With