I think I found a bug in The C Programming Language 2nd ed. book

I think I found a bug in The C Programming Language 2nd ed. book.
In the while loop, they didn't put the braces.
I think they meant to say this:
while ((c = getchar()) != EOF) {
if (c >= '0' && c

Attached: 1648640299165.png (856x758, 102.43K)

No, they were right. An if / else if / else statement is technically one statement and can be written on one single line without semicolons. C allows you to skip using a brace in a for or while loop if youre only making one statement inside it. A statement != a line of code. One statement can be several

Its a retarded style but its valid and not a bug

>if youre only making one statement inside it
I was too lazy to write all the code, but look at picrel, there's more than one statement.

did you try actually running the code?

Attached: 1566181909144.gif (236x250, 1.47M)

the whole if, else if, else is one statement

I thought you downloaded the pdf which was like a pdf's software's inperpretation of the book, which was then transcribed.
That was my first C book, and I was so confused because there were errors everywhere, but it was due to the interpreter. The original books was more or less fine.

>new programmer
>assumes that he is not the one making the mistake
ngmi.

welcome to Any Forums, full of dunning krugers

Whats a dunning kruger?

Wait, I did test it before and it kept printing a new line each loop, so that whole if else is one single statement?

someone that is over confident of their abilities/knowledge and still fails. despite their ability/knowledge to be severely lacking, they believe they know everything about whatever topic or skill it may be.

Now i feel embarrassed, I thought I had uncovered a big mystery, it was user error all along.
At least I know now that a sequence of: if, else if and else are a single statement.
I think what I did was I made two "if" statements.

gmi

You fucking retard, read what I said.

no

honestly it's not nice formatting, i would say the authors should just be explicit and add the braces, especially if they're teaching. is there any reason they should do what they did aside from habit and shorthand?

every single person does it bro, you're good we're all learning

It works but this style is banned in the Linux kernel for example, all control statements are required to have curly braces even if it has just one statement/line.

but I like it this way, however.
it makes it look less cluttered, albeit at the cost of readability.

readability is so important, i don't mind a few braces.

wholesome
gmi
>Verification not required.
Beautiful day

No need to state the obvious, but if you like it that way, use it like that in your projects. But stick to the rules other projects have or you'll just have every single PR rejected and you will be laughed at and you will be sad

managing two different styles is hard, it even says so in the book
>stick to one style
or something, I don't remember. I'll use the braces, I don't want to be laughed at and be sad.

>managing two different styles is hard, it even says so in the book
I can manage several personalities and I'm doing just fine (my skin is falling off)
>Verification not required.
This is the best day of my life (despite my eyes bleeding)

I thought this wasnt true. I'm glad this is the case now. I hate people who don't use braces on conditionals. Drives me up the wall, and its asking for bugs.

>(my skin is falling off)
>(despite my eyes bleeding)

Attached: 1631488178350.jpg (960x954, 42.25K)

Attached: WEahjeasdasA.png (413x458, 255.94K)

>gmi
Go back to Any Forums retards. Your "hurr durr bro u gonna make it" niggerspeak isn't welcome here.

>Go back to Any Forums retards.
Ive never even been on Any Forums!
FRIG YOU!!!!

Attached: 260px-OP_C057_asuka.jpg (260x195, 23.21K)

...