D - string split method silly
- Paul Stanton (14/14) Jan 23 2003 is it just me or does this look a bit funny...
- Walter (5/19) Mar 06 2003 This is happening because %s is expecting a null terminated string. char...
is it just me or does this look a bit funny... { char[][] result = split("garry,barry,harry", ","); for(int i = 0; i < result.length; i++) printf("%s\n", (char*)result[i]); } prints: garry,barry,harry barry,harry harry personally, i was expecting garry barry harry
Jan 23 2003
"Paul Stanton" <Paul_member pathlink.com> wrote in message news:b0por5$5dc$1 digitaldaemon.com...is it just me or does this look a bit funny... { char[][] result = split("garry,barry,harry", ","); for(int i = 0; i < result.length; i++) printf("%s\n", (char*)result[i]); } prints: garry,barry,harry barry,harry harry personally, i was expecting garry barry harryThis is happening because %s is expecting a null terminated string. char[] in D are not null terminated. Try using %.*s instead, and you should get the answer you expect.
Mar 06 2003