Hi, I get the error "warning: array ‘str’ assumed to have one element [enabled by default]" when I am trying to fill in values inside the string array.
#include<stdio.h>
#include<string.h>
#include<malloc.h>
char* str[];
int i = 0;
int main(void)
{
for(i=0;i<5;i++)
str[i] = (char*)malloc(200 * sizeof(char));
strcpy(str[0],"hello");
strcpy(str[1],"my");
strcpy(str[2],"name");
strcpy(str[3],"is");
strcpy(str[4],"tubby");
for(i=0; i<5; i++)
printf("[%s]",str[i]);
return 0;
}
What is the cause for this warning? Yes the output is getting displayed correctly, but why the warning ?
Please note that I have already done a malloc and created a space of 200 characters for each of the strings.