#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main() {
const char* hello = "Hello, World!";
char *str = malloc(14 * sizeof(char));
for (int i = 0; i < 14; i++) {
strcpy(str[i],hello[i]);
}
str[14]='\0';
printf("%s\n", str);
return 0;
}
Compilation warnings:
warning: passing argument 1 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion] note: expected 'char *' but argument is of type 'char' warning: passing argument 2 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
str is a pointer and hello too, what's going on?