So if your input file has a line like 1.1.1.1\n Note also that if fgets() encounters a newline and there's room in the target array for it and the terminating nul, fgets() will store the terminating newline before the nul character. Note that fgets() will write a terminating nul character (0) to the end of your string. What all this means is that fgets() will read up to the next 12 characters (provided it doesn't hit a newline or EOF first) and store it starting at list. List char char (*) (pointer to 12-element array of char) In that case, the type of the array expression is not converted to a pointer type, and the sizeof operator returns the number of bytes in the array type (12). Note that I also passed that same expression to the sizeof operator. Even though the type of list is "12-element array of char", in this context it is implicitly converted to type "pointer to char", and the value will be the address of list. Note that in the code above I passed list as the first argument to fgets() without any decoration (such as the
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |