Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Strcpy versus Strncpy in arrays
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Dave Thompson, post: 2437119"] So %s, which will (normally) store _at least_ 1 data character plus a null terminator character, is UB. Use %c, and perhaps " %c" to skip leading whitespace. Better yet, don't use scanf at all: FAQs 12.12-20 at usual places and [URL]http://www.eskimo.com/~scs/C-faq/top.html[/URL] But if it _were_ a string, then just substituting again == "Y" is wrong in a different way; FAQ 8.2, or use again[0] == 'Y'. - David.Thompson1 at worldnet.att.net [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Strcpy versus Strncpy in arrays
Top