Problem with string copy

why strcpy runs with case 2. but not with case 1 ? bith have same type of arguments…

@gaurav19063,
strcpy(), takes char* as argument not string.

but have a look at the code it is taking string as an argument

@gaurav19063,

  1. is taking a string as parameter, and that is why giving compilation error
  2. is taking char* as parameter, and that is why working perfectly (Yes, “hello” is a char array not string)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

strcpy(a,“hello”) ;// 2.
But it is a string not a character array.

@gaurav19063,
Why do you think so…??

it is written in chords thats why…

@gaurav19063,
Written in chords means character array implicitly.

1 Like