4 ms·
Why in matchstar does c have type int instead of char? Is this some holdover from K&R C?
by ridiculous_fish 4y ago
Why in matchstar does c have type int instead of char? Is this some holdover from K&R C?
- eesmith 4y agoInteresting. I see elsewhere that "int" is used where "char" should be fine, specifically, "int sepc" on page 97 of https://archive.org/details/practiceofprogra0000kern/page/96/mode/2up https://archive.org/details/practiceofprogra0000kern/page/96... , used only for a (char*)[0] and a test against ','. While the C++ code on page 101 at https://archive.org/details/practiceofprogra0000kern/page/100/mode/2up https://archive.org/details/practiceofprogra0000kern/page/10... uses a "char c" parameter. There's also some "unsigned char c" at pages 169 and 170, at https://archive.org/details/practiceofprogra0000kern/page/168/mode/2up https://archive.org/details/practiceofprogra0000kern/page/16... , in C code. I'm going to guess it's from habit of using "int c" with getchar() to prevent confusion between EOF (-1) and 255. Discussed at https://archive.org/details/practiceofprogra0000kern/page/194/mode/2up https://archive.org/details/practiceofprogra0000kern/page/19... .