gets always shows the warning because it,s takes always more than given space so unused space is waste in gets but fgets not take more than declayred space.but if we don,t know the size of data then gets is useful and gets work after warning by default
main() { char buff[5]; gets(buff); printf("%s",buff); } The code is simple, it reads string and prints the entered string, provide the program a string of 10 bytes it will save the whole 10 byte in memory. means gets() doesn’t do any testing of how much memory the array has and keeps on reading the whole string. so there is possibility of overwriting data of some other memory location which is not allocated to the array.