Not only are you confusing the order or parametres in strcpy
(it’s destination, then source, so strcpy(xstring, animalsarray[j][0]);
would have it’s parametres inverted), you’re confusing a char
with a pointer-to-char
.
xstring
is a char, and you’re trying to use it as a string.
If you want to set all the elements of the array to the 'x'
character, try using memset
instead.
for(j=0;j<100;j++){
memset(&animalsarray[j][0], 100, 'x');
}
Although this doesn’t set the last character of the array as '\0'
, so you don’t have 0-terminating strings. To have this, add animalsarray[j][99] = '\0';
just after the memset(...);
.
If you do want to use xstring
as a 0-terminated string, it would have to be initialised thusly:
*xstring="x";
solved both are char but i get, invalid conversion from `char’ to `char*’ [closed]