Omg

Omg...

Attached: Untitled.png (662x499, 15K)

Other urls found in this thread:

en.cppreference.com/w/cpp/io/manip/boolalpha
twitter.com/SFWRedditVideos

What are you doing?

Use debugger, retard. Your cin gives you false for some reason.

>default case for 2 state boolean
cs_grad.png

You input string and compare it to boolean. You have to cast string to bool before switch.

Maybe cin fails and gives special value...
Whats a good debugger to use?

did summer end? now Jow Forums seems to be full of people like

I didn't realised the b is bool. I'm not sure if you can use cin to fill a bool.

I can't stop laughing. It's just imagining a legit program like grep going WHAT?!??
Not him but operator>> is overloaded for basic types, no t cast from string.

it gets stored in the bool, so it can only be true or false
the real meme is that I'm pretty sure that std::istream doesn't take "true" or "false" for bools, and instead treats it as an number (0 for false, anything else as true), unless you set boolalpha flag for the stream
std::cin >> std::boolalpha >> b;

please contact the relevant cpp docs such as cppreference.com while learning

Anything that isn't 0 is true so this is working as it should

based retard

Offff omg

Attached: Untitled.png (774x693, 42K)

'0' isn't 0

Do people even use cin and cout unironically?
All I've ever seen in actual programs were scanf and printf.

> cin into a bool
state of Jow Forums

0 is false.

Uhhhmmmm??? 0 gave false, true gave false too.
Its the best..... I am not allocating memories and checking buffer lenghts

C# doesn't have this problem.

Bool doesn't exist in C. C++ pretends like it has bool but it actually doesn't exist in there either. 0 and 1 should give what you expect.

Stop typing like a retard

Lol
But 1 as true is different from not-0 as true.

0 is false, works as expected

Print out the contents of b before the switch statement. That will help you to understand what the switch statement is doing.

Ah yes, C/C++ type unsafety

rewrite it in Rust

Attached: 1563031377828.jpg (611x560, 60K)

Use en.cppreference.com/w/cpp/io/manip/boolalpha

>tralse x = y
you know for floats which uses the jew standard iee, tralse is actually legit.

>tralse
Gets me every time.

Does 1 give you true?

> y = 0

1. Y = 0 breaks
2. X = 0, Y != 0 always false
3. X=Y!=0 tralse

Since nobody actually fucking answered the question, bool is treated as a number here. 0 is false, any other number is true. The cin fails because "false" isn't a number.

I did.
Is the solution.

bool doesn't exists on x86. because it can not address it. every bool operation is bit shifting. look at std::bitset! sizeof(bool) is 1byte. C++ standard require that a bool must have a address. It is a system level programming language not every human has a brain big enough for it. thats why python exist.

#include

using namespace std;

int main()
{
bool value;

*(char *)(&value) = 2;

switch(value){
case true: cout

breaks on hypothetical machine where bool is 1bit :D you shall not pass code review.

Abusing the type system is undefined behaviour.

>bool can't be anything but true or false
>here you go, it can in some cases
>but that's undefined behavior! in some cases it won't work
are you fellows ok

undefined behavior is necessary because else the C++ standard had to define how different CPU behave. The C++ abstract machine had no mt in the past. in fact all os from the past used ub for mt.

Hahaha nice bait OP, I'll give you that.

>std::cin >> b;
C++ was a mistake.

Attached: 1542259013965.png (500x522, 133K)

>m-muh undefined behaviour REEEEEEEEEEEE
Fuck off. If it works on your target compilers, who gives a shit about what the standard says?

Thanks, I acutally got it off govnokod.ru

>undefined behavior is necessary because else the C++ standard had to define how different CPU behave.
No, it doesn't have to. It only has to define how its abstract machine works with less ambiguity, which is the effect of reducing undefined behavior.
Mapping said abstract machine semantics to real CPU instructions is, and has always been, the implementation's job (usually a compiler in the case of C++), not of the language specification itself.

the stupidity in this thread gives me hope for escaping the world of webdev into an embedded job

Attached: Screen Shot 2019-05-10 at 1.18.46 AM.png (250x306, 99K)

If you end up in memes such as IoT, it's arguably even more brainless than webshit nowadays.

>tralse
chest... pains...

I'm almost landing an automotive embedded job so no IoT trash for me, automotive grade linux gives me a nut.

Clearly you are a "special needs" developer, or a mentally ill tranny or a LARPing retard.
>True is all lowercase in the output yet the source codes is in uppercase.
What is this retardation?. kys.

>Read whatever is in the console to the variable b.
Pretty much straight forward.

Omg I am LEARNING you were stupid when you started out

Dilate more.

Attached: tranny.jpg (640x732, 567K)

to you and everyone in this fucking thread
learn how god damn memory works jesus christ

Attached: Screen Shot 2019-08-08 at 5.03.33 PM.png (336x326, 64K)