I feel silly for asking, but I had trouble finding my answer. How do I re-assign “Rose” to “Douglas”? It seems like I have to use a loop.
#include <stdio.h>
int main() {
char arr[3][12]= { "Rose", "India", "technologies" };
printf("Array of String is = %s,%s,%s\n", arr[0], arr[1], arr[2]);
arr[0][0] = {"Douglas"};
printf("Array of String is = %s,%s,%s\n", arr[0], arr[1], arr[2]);
return(0);
}
You can do this with
strcpy():When using
strcpy(), you will have to ensure that there is enough space in the destination to hold the string you’re putting there (plus the terminating NUL character). In this case there is, because you have allocated 12 bytes for each string and"Douglas"will take 8.