C language – if you are not a programmer, you will never understand these three symbols! (= and = =,! =)

Time:2021-10-16

1. =:

In C language, the equal sign (=) is the assignment operator. The following is a brief description of the use of the assignment operator

1) Assignment of variables:

inta;

a = 10;

Here is the assignment of 10 to A. after the assignment, the value of a is 10

2) Assignment of pointer variable:(assignment of address and pointer variable respectively)

First:

intarr[999] = { 0 };

int*p = NULL;

p = (int*)&arr;

Define an int (integer) variable arr, and initialize each array element in the array of arr to 0

Define an int (integer) pointer variable p and initialize it to null (null pointer)

&(take address character), & arr means to take the memory address of arr, and then convert it to an int (integer) pointer variable through (int *)

Finally, through the assignment (=) operation, the address of arr is saved to P (integer pointer variable)

PS: & arr and & arr [0] are the same. They are the memory address of the first element in the array

Second:

int arr[999] = { 0 };

int *p = NULL;

int *p1 = NULL;

p = (int *)&arr;

p1 = p;

There are two more places here than above

Define an int (integer) pointer variable P1 and initialize it to null (null pointer)

Through the assignment (=) operation, P is assigned to P1. After the assignment, P1 and P save the memory address of arr.

 

2. = = and! =:

==And= Is a relational operator PS: < =, =, >, = == Are relational operators

=And = =, we often see that = (assignment operator) is mistakenly used to judge whether the two sides are equal when using if (conditional judgment) for judgment

1) ==:

a == b

Judge whether a and B are equal

Equal returns true, otherwise false

2) != :

a != b

Judge whether a and B are not equal

True is returned for non equality, otherwise false is returned

summary

This is about = and = =,, in C language= That’s all for your article. If you have any questions, please leave a message in the comment area.

 

Finally, if you want to be a programmer and want to master programming quickly, join quicklyLearn Penguin circle

There are senior professional software development engineers to answer all your doubts online ~ introduction to programming language “so easy”

Programming learning books:

 

Programming learning video: