3 ms·
The number of times students have come to me absolutely baffled as to why they can't tokenize a string twice using strtok() is the best reason for function puri
by ModernMech 6y ago
The number of times students have come to me absolutely baffled as to why they can't tokenize a string twice using strtok() is the best reason for function purity I can think of. It's such an abomination of a function. The first time you call it, you give it a string and a delimiter. Subsequent times you call it, you give it a NULL and the delimiter. And then once you've tokenized the string once, you can never use it again. It's an example I hold up of how not to design functions.