My point is that mindless copy-and-paste should be limited to when you're learning your first language. C is not a very good first language and at this point I doubt it's a very common one.
C is not a very good first language and at this point I doubt it's a very common one.
There are many people for whom C is a first language, especially those in electrical or mechanical disciplines whose introduction to programming involves microcontrollers. The number of people learning C not as a first language but still early on in their education is non-trivial too. Even people who have been programming a while will have some trouble with the concepts of pointers and null terminated strings which they likely haven't encountered before C and they do resort back to grabbing code.
Even when someone is past the point of copy and paste, they expect learning materials to be examples of the 'right' way to do something in an environment that is new to them. I've been programming for ages and am learning erlang right now, to a large extent I rely on the learning materiel I'm using to show me the time-tested solution to problems that have been solved over and over again for that language. Not because I couldn't do it my way, but because I'm building in a new environment where I don't know all the ropes and expect learning material to guide me. After all, thats what its for.
Lets look at this from the other side. Lets say someone has been programming C for decades, but has never used a SQL RDBMS. Now he's learning PHP to make himself a website. Is it fine for php guides to rely on his experience as a programmer and just use some shitty hacked together SQL escaper, or should the guides use the baked-in sanitation utility is?