C Strings and my slow descent to madness
deusinmachina.net
C Strings and my slow descent to madness
1–10 of 329 posts
Re: C Strings and my slow descent to madness
#2 const char *s = "Hello World!";
const char *world = s + 6;
size_t world_len = 5;
printf("%.*s\n", world_len, world);Re: C Strings and my slow descent to madness
#3Re: C Strings and my slow descent to madness
#4Yes it is. And I bet on a modern windows version it is too. The terminal has been (probably intentionally) neglected by ms for a long time, but as far as I know this has mostly been fixed on modern windows versions.
EDIT: Author admits it later in the text "will be fixed in Windows 11 and Windows Server 2022"
Also it says "strlen("有り難う")); [...] and the output is… The length of the string is 12 characters". But according to "man strlen": "RETURN VALUE: The strlen() function returns the number of bytes in the string pointed to by s.". It says nothing about "number of characters".
Re: C Strings and my slow descent to madness
#5I’ve also been having a blast with C because writing C feels like being a god! But the biggest thing that I like about C is that the world is sort of written on it!
Just yesterday I needed to parse a JSON… found a bunch of libraries that do that and just picked one that I liked the API.
Re: C Strings and my slow descent to madness
#6https://man.openbsd.org/strlcpy.3
https://man.openbsd.org/wcslcpy.3
which to me will help with some of these issues. Too bad other Operating Systems do not have these. On Linux there is libbsd to get these, but I would like to see these to be added to the stdc.
Instead the c23 standard is messing with realloc(3) which could break some old programs. I have not looked at that in detail yet, so maybe it is a non-issue :)
Re: C Strings and my slow descent to madness
#7Re: C Strings and my slow descent to madness
#8Re: C Strings and my slow descent to madness
#9Re: C Strings and my slow descent to madness
#10> If we try to print out some Japanese characters… [] The output isn’t what we expect. Yes it is. And I bet on a modern windows version it is too. The terminal has been (probably intentionally) neglected by ms for a long time, but as far as I know this has mostly been fixed on modern windows versions. EDIT: Author admits it later in the text "will be fixed in Windows 11 and Windows Server 2022" Also it says "strlen("…