O'Reilly logo
  • Imran Shaikh thinks this is interesting:

Using sizeof with fgets()

The code above sets the maximum length using the sizeof operator. Be careful with this. Remember: sizeof returns the amount of space occupied by a variable. In the code above, food is an array variable, so sizeof returns the size of the array. If food was just a simple pointer variable, the sizeof operator would have just returned the size of a pointer.


Cover of Head First C


Sizeof with fgets()