I’m getting the segmentation fault error for the inner while loop.
char **c;
c=(char **)malloc(3*(N-1)*sizeof(char *));
for(int i=0;i<3*(N-1);)
{
char *temp;
gets(temp);
while(*temp!='$')
{
j=0;
while(*temp!=' ')
{
*(c[i]+j)=*(temp+j);
j++;
}
i++;
}
i++;
}
sorry for improper indentation.I know that manipulating char * strings would cause an error.But I am not sure about this error.I was tring to break tmp string into three different strings.
1)
tempshould be a block of memory (buffer) to copy thegetsstring.2) for the line
and
we expect to find some incrementation for
temppointer (for exampletemp++) for both loops but there is not. and this cause a problemIf I can guess your need, here after a suggestion of your code fixed ( I did not test it)