What is the difference between =! and != in C?

what is the difference between =! and != in C?

when I write " current->next =! NULL " it gives no error when compiling but the program crashes. I dont understand why it even compiles.

void push(node_t *head, int val) {

node_t *current = head;
node_t *new = malloc(sizeof(node_t));

if (new == NULL){
return(1);
}

while ( current->next != NULL){
current = current -> next;
}

current -> next = new;
new -> next = NULL;
new -> val = val;
}

!= is a comparison operator, while =! sets a variable to the NOT of the right side

fag != NULL is different to
fag = !NULL

so it sets it to any random variable that is different from the left side?

this
it's not =! null but = !null

It sets it to the NOT of the right side variable, NOT is an operation like AND/OR/XOR/etc, basically just flips the bits of the variable

So if you had fag =! 0, that would set fag to the NOT of 0 which should be 0xFFFFFFFF, and vice versa I suppose

No, it sets it to !NULL. Which is 1. Which is not a sensible pointer value, and breaks when you try to dereference it.

it sets it to 1 if right side is equal to 0 and to 0 if right side > 0

Hahaha, you're fucking dumb.

No, that's the ~ operator, not the ! operator. The ! operator maps 0 to 1 and anything else to 0. So !NULL is 1, not 0xffffffff or anything like that.

s/>/!=

i += 1;

is different from

i = +1;

Oh yeah your right, knew I had something wrong after posting that

But yeah anyway OP, IIRC there's no actual valid comparison operators that start with =, other than "==" ofc (the rest are = != etc)
So if you ever see an if statement that has an operator starting with "=" it's safe to say that the statement is setting the variable instead of comparing it, which some compilers will warn about but not all

ok I got it . thanks.


x =! NULL = 1

Yes but to be pedantic
(!NULL == 1) == true
x = !NULL
(x == 1) == true

!= 5 means "NOT equal to 5"
=! 5 means "equal to NOT 5"; it is equivalent to = !5

What the fuck is !5? Wouldn't that give an error?

Logical unary NOT returns 1 if given a non-zero operand, and 0 otherwise. That's all.

Oops. Other way around.

It's late.

Any primitive type in C can be treated as a boolean. That includes integers and pointers. The bool type didn't get introduced until C99.

>18 years later and we still use 28 years old language
Seems like fine.

Just because something is old does not automatically make it bad.

Can you stupid cturds please stop re-implementing the fucking linked list over and over again?
Not only is it a problem that has been solved millions of times already, the linked list as a data structure sucks ass.

I'm starting to wonder if linked lists are the only thing the average Sup Forums c programmer can program.

And every time niggers are reimplementing and reimplementing Booleans just because they don't use modern languages.