Skip to contentSkip to conversation

erroneous scanf's %s pointer description

DISCUSSION Stefan Tauner 2 participants 2 messages Dec 2, 2015 – Dec 4, 2015 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

Hi,

I have noticed that the description about the %s type modifier in the official scanf man page is a bit misleading (man3/scanf.3:454). It currently states "the next pointer must be a pointer to character array". However the (C99) standard says "the corresponding argument shall be a pointer to the initial element of a character array".

So IMHO the wording of the man page is sloppy at best - a pointer to an array is not the same as a pointer to its first element (which can also obtained by just supplying the name of the array). This led to some confused students and lecturers here ;)

The man pages of e.g. FreeBSD and Opensolaris contain "the next pointer must be a pointer to char" and "a pointer to the initial byte of an array of char" respectively. I have not checked others.

KR

Signature · 14 lines
Dipl.-Ing. Stefan Tauner
Research and Development
Embedded Systems Department

University of Applied Sciences Technikum Wien
Hoechstaedtplatz 6, 1200 Vienna, Austria
T: +43 1 333 40 77-316
E: stefan.tauner-1IEs1BiS2Ng4SCxGYwAy/[email protected]
I: embsys.technikum-wien.at
I: www.technikum-wien.at
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

Hello Stefan,

Quoted 7 lines · Stefan Tauner

Hi,

I have noticed that the description about the %s type modifier in the official scanf man page is a bit misleading (man3/scanf.3:454). It currently states "the next pointer must be a pointer to character array". However the (C99) standard says "the corresponding argument shall be a pointer to the initial element of a character array".

Fair enough. I changed the text of the page as you suggest. Thanbks for the report.

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html