hi all
i'm trying to do array of pointers, each pointer is a string.
can any one help me please, this is my code:
whats wrong with my code???!!!PHP Code:
int main (void)
{
int i, max=0, ext=0;
char *str, ch;
str =(char *)malloc(10 * sizeof(char));
char **s =(char **)malloc(10 * sizeof(char));
if(str == NULL)
printf("\nError...\n");
else
{
i=0;
do
{
s[i] =(char *)malloc(10 * sizeof(char));
scanf("%c", &ch);
while (ch != '\n')
{
*str = ch;
str++;
scanf("%c", &ch);
}
strcpy(s[i], str);
i++;
}while (*(s[i]) != "Stop"); //the error is here.....!!!
max = i;
//printf("\nname is = %s\n", str);
//puts(str);
for(int j=0; j<max; j++)
{
puts(s[j]);
}
}
return 0;
}