The strlcat() function (with the L) achieves the same goal as the venerable strcat() function: to append one string onto the end of the other. The problem with strcat(), however, is that a size limitation isn’t set for the destination buffer. It’s quite possible for this buffer to overflow.
Continue reading
Author Archives: dgookin
My Own strlcpy() Function
Armed with information about how the non-standard strlcpy() function is implemented by my compiler (see last week’s Lesson), and fully testing its input and output, I was better able to craft my own version. Granted, it’s not the way I would have coded things on my own, but the point is to recreate the function exactly so it can be used as a substitute.
Continue reading
Morse Code Filter – Solution
A Morse Code filter probably has no practical use, but it’s a good programming exercise. The issue is how to deal with undefined character codes and otherwise present the output. My solution for this month’s Exercise involves interpreting standard input, discarding undefined information, and sending the results to standard output in a format that isn’t ugly.
Continue reading
Non-Standard Function: strlcpy()
I though writing a substitute strlcpy() function would be easy. Boy was I wrong!
Continue reading
Morse Code Filter
I’m certain that the nerds would love debating whether the telegraph’s Morse code system was the first binary communications network. Let them do so. Still, Morse code remains a simple communications system, translating letters and numbers into dots and dashes — which you could argue are similar to ones and zeros.
Continue reading
Non-Standard Function: strcasecmp()
As part of my research, I run my C code on different platforms using different compilers. Occasionally I’m crushed to discover that my code won’t compile because my development computer uses a customized version of the C library, one that features a non-standard function, such as strcasecmp().
Continue reading
Functions as Structure Members
A programming puzzle kept me awake one night: If a structure allows for any variable type to be a member, and a function is a valid variable type, why not have a structure with a function as one of its members? Am I nuts?
Continue reading
Deviously Playing with Memory
When a buffer is void, its contents are treated as raw memory, not assigned to any specific data type. This ambiguity means your code can cast the memory’s data type and do interesting things with it.
Continue reading
Playing with Memory
Gone are the old days when your C program ruled the entire computer’s domain. Back then, you could access any chunk of memory in the computer, manipulate it in all sorts of interesting ways, and not be concerned that your code’s actions would be restricted. Ah, those were good times.
Continue reading
The Yorn Function – Solution
The most difficult thing about this month’s Exercise is to deal with stream input: When the user overstuffs the input buffer, those extra characters continue to flow into the program, interpreted as additional input and they make the output look ugly.
Continue reading