Quote:
hello and I receive ello
char *input()
{
printf("Give: ");
char *word = malloc(sizeof(char) * 50);
fgetc(stdin);
fgets(word , 100 , stdin);
return word;
}
[Update]
Try to replace:
fgets(word , sizeof(word) , stdin);
with:
fgets(word , 100 , stdin);
word is a pointer, its size is the size of the pointer, not the size of space it is pointing to.
In C/C++, arrays have np knowledge of their own size.