TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Deconstructing "K&R C"

6 pointsby thatmiddlewayabout 13 years ago

4 comments

zedshawabout 13 years ago
Just for the record, I am as sick of this part of the book showing up on HN as everyone else. I do not post it here, other people do, and I apologize in advance for it showing up here all the time half-finished.<p>But, if you have a problem with this I ask that you write code disproving that the copy() function does not terminate for all possible inputs. Or, that you write a function that can check if a C style string is valid. If someone can do that it'd help me with the book.
评论 #3649321 未加载
评论 #3649038 未加载
jleaderabout 13 years ago
For people who say "C strings are null-terminated and you don't pass their length, get used to it", let me point out <a href="https://www.securecoding.cert.org/confluence/display/seccode/API02-C.+Functions+that+read+or+write+to+or+from+an+array+should+take+an+argument+to+specify+the+source+or+target+size" rel="nofollow">https://www.securecoding.cert.org/confluence/display/seccode...</a>, which is part of the "CERT C Secure Coding Standard", and the new bounds-checking features in C11 (which I haven't actually seen yet).
Turing_Machineabout 13 years ago
"because it does not terminate cleanly for most possible inputs"<p>"Most possible inputs", meaning "random garbage"? Insisting that an algorithm "terminate cleanly" on every possible input is... a somewhat high standard.<p><a href="http://en.wikipedia.org/wiki/Halting_problem" rel="nofollow">http://en.wikipedia.org/wiki/Halting_problem</a>
评论 #3649001 未加载
评论 #3648995 未加载
thatmiddlewayabout 13 years ago
I'm interested to see what people have to say about this as someone who is looking in to learning C.
评论 #3649237 未加载