hello guys,
i wirting a program to read a string using s fgets function. look in to the code what i havw written.
when i run this program i allocated only 3 bits int the memory rather than allocating 10 bytes. and here is the sample output of what it doesCode:#include<stdio.h> #include<string.h> int main() { char *p; p=(char *)malloc(sizeof(char)*10); fgets(p,sizeof(p),stdin); fputs(p,stdout); getchar(); }
i don't understand why it is can any one can explain what it is pleaseCode:hello world hel
thax very much in advance