u/Competitive_Brick574

Help me understand NUL please!
▲ 9 r/programminghelp+1 crossposts

Help me understand NUL please!

https://preview.redd.it/wpno1k6lmath1.png?width=384&format=png&auto=webp&s=c95e3b46b59f9d359529071e44dc7bbb305a39f1

Hello everyone, currently in Week 2 (and really enjoying it). I understand the concept of NUL marking the end of a string.

I was playing around with this with the programme above (Input is Hello), but I am a little confused because all of the conditionals come out as 1 (true). In my mind [5] should be the only true value index after the end of the string... but I am very confused as to why [6] and [7] are also showing as true.

Interestingly, if I hard code the sentence variable to "Hello" (instead of getting it via the get_string function), I get the expected answer of 1,0,0.

I think this might be related to the values that are being held in memory... but cannot seem to find an answer, so would appreciate any insights to make sure I understand the concept thoroughly. thanks all

reddit.com
u/Competitive_Brick574 — 12 days ago