5 ms·
I worked on a Win32 app that used space-padded strings, i.e. the destination string was padded with spaces, but there was still a null on the last byte. You had
by PlunderBunny 3mo ago
I worked on a Win32 app that used space-padded strings, i.e. the destination string was padded with spaces, but there was still a null on the last byte. You had to use special versions of the string functions for length, copy etc.
I’m not sure why this was - the source base was so old it might have had its origins in Pascal struct behaviour.
- bebe83939 3mo agoPerhaps prevent realocation when string size changes? Or aligning cpu cache lines?
- jkfkfkj 3mo agoIt can perhaps be due to the string originating from a sql database ”char” field, I.e. not ”varchar”. Char fields in databases are space padded.
- egorfine 3mo agoI think this behavior has its roots in COBOL, not pascal.
- kps 3mo agoWhich has its roots in punch cards, where pre-computer hardware operated on fixed-sized fields and an unpunched column is equivalent to a space.