char *pointer[100];
.
.
.
int input()
{
int i=0; int length; char help[100];
printf("Input: ");
scanf("%s",help);
while((strcmp(help,"ENDE")!=0)&&(i<100))
{
length=strlen(help);
pointer[i]=(char*)malloc((length+1)*sizeof(char));
pointer[i]=help;
i++;
printf("Input: ");
scanf("%s",help);
}
return i;
}
if I enter a word and assign it to pointer[i] (how showed above), the program overwrites all elements (pointer[0] until pointer[i-1]) with this last entered word. if I want to output all elements at the end of the program (not showed above) the program puts out strange signs (always the same "smiley").
Whats going wrong here??????



LinkBack URL
About LinkBacks



