3 ms·
If only C had followed the Pascal way to have the size with a string - so much human suffering could have been avoided!
by lenkite 6y ago
If only C had followed the Pascal way to have the size with a string - so much human suffering could have been avoided!
- throw0101a 6y agoIt was considered: > C designer Dennis Ritchie chose to follow the convention of null-termination, already established in BCPL, to avoid the limitation on the length of a string and because maintaining the count seemed, in his experience, less convenient than using a terminator.[1][2] * https://en.wikipedia.org/wiki/Null-terminated_string#History https://en.wikipedia.org/wiki/Null-terminated_string#History Richie et al had experience with the B language: > In BCPL, the first packed byte contains the number of characters in the string; in B, there is no count and strings are terminated by a special character, which B spelled *e. This change was made partially to avoid the limitation on the length of a string caused by holding the count in an 8- or 9-bit slot, and partly because maintaining the count seemed, in our experience, less convenient than using a terminator. * https://www.bell-labs.com/usr/dmr/www/chist.html https://www.bell-labs.com/usr/dmr/www/chist.html