Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Campbell Ritchie wrote:Have you verified where that \001 is in you file? Have you verified that all the characters in that file are ≤ 0xff? What is the encoding for your file? If you have any characters ≥ 0x100, or anything non‑ASCII, there is the possibility of an unexpected pairing.
Tim Holloway wrote:This is kind of gauche to me: "memset(left, '\0', 50)". If, as I presume, you mean for '\0' to stand for the octal byte value \000, I'd recommend that you follow common practice and write all 3 digits.
Although in actual fact, I'd simply code "memset(left, 0, 50)", as "0" is the universal nothing in C, signifying ASCII NUL, floating-point 0.0, and null pointer value (which, interestingly, on some systems is not actually address 0)..
Then again, I think that there may be a standard memset-equivalent that's explicitly intended to deal with character arrays. A character, after all, isn't always exactly one byte in the wider world.
As to getting a binary 1 for pass 1, my first instinct would be to see if the loop index was somehow getting pushed into a character.
But I think your code would probably be clearer (and easier to debug!) if you considered doing that central loop block using a switch statement.
I think the intention is to set the whole buffer to the end of string character '\0', which is at least logically different to '\000' and correct in this context. But as I mentioned above unnecessary.Tim Holloway wrote:If, as I presume, you mean for '\0' to stand for the octal byte value \000, I'd recommend that you follow common practice and write all 3 digits.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
John Matthews wrote:
I think the intention is to set the whole buffer to the end of string character '\0', which is at least logically different to '\000' and correct in this context. But as I mentioned above unnecessary.Tim Holloway wrote:If, as I presume, you mean for '\0' to stand for the octal byte value \000, I'd recommend that you follow common practice and write all 3 digits.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
I find that very hard to believe - it's basic stuff, page 37 of The C Programming LanguageTim Holloway wrote:I've never seen '\0' used as a NUL.
Sorry - printed page 31.John Matthews wrote:page 37 of The C Programming Language
http://www2.cs.uregina.ca/~hilder/cs833/Other%20Reference%20Materials/The%20C%20Programming%20Language.pdf
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
I'm curious to know where that world is, because it's obviously very different to the un-real world I've been (professionally) writing C in, start-ups and multi-nationals, for the past 30-odd years where I don't remember anyone ever using anything other than '\0' as a string terminator. That's a genuine question. And again if you can show me anything online that uses/advises something different I'd be interested - C specifically as that's mostly what I do. You learn something new every dayTim Holloway wrote:You win
. But as I said, in the real world, I've not seen it used.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Definitely. But would you define constant for the tab character '\t'? Or newline '\n'? Perhaps you would. But anyway, '\0' isn't any different to those - the number 0 isn't really a number in this context, it's just part of the 'symbol' for the NUL character.Tim Holloway wrote:Still, I do recommend manifest constants rather than "magic numbers", no matter what syntax you use.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Don't get me started on my problems...Tim Holloway wrote:What's more important: did you resolve your problem?
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Uh oh, we're definitely being carded. Here, show him this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|