当前位置:网站首页>C language learning log 12.5

C language learning log 12.5

2022-06-13 04:57:00 Today is also a day without baldness

One . Two dimensional array

Format :int a[x][y]: The representative definition has x That's ok y Columns of the matrix , It can also be y That's ok x Columns of the matrix , In order to conform to Linear Algebra , Generally, we think it is the first case .

Two . Array application

 eg: When an array is used as an argument in a function , Often you have to use another parameter to pass in the size of the array

3、 ... and .Sizeof:

An operator , Single purpose . In fact, it gets the storage space occupied by data in memory , Count in bytes

(1). For data types : Format :sizeof(type);

(2) For variables : Format :sizeof(name);

eg:sizeof Operators cannot be used with functions !!!

(3) As a result, : The integer is usually 4 Bytes , Single precision is also 4 individual , Double precision floating point numbers are 8 individual , The character type is generally 1 individual

Four . The pointer

& Is used to get the address of the variable , His operands must be variables . Is the address the same size as int About depends on compiler

int i; printf("%p",&i);

* Is a unary operator , The value of the variable used to access the address represented by the pointer variable , It can be an R-value or an l-value .

int k=*p;     *p=k+1

Tips: An array in a function is a pointer, that is :

int *a And int a[] Equivalent

Array variables are special pointers , Its own expression address so

int a[10]; int*p=a // No need & Address fetch

But the elements of an array represent variables , Need to use & Address fetch

a == &a[0]

[] Operators can be used for arrays or pointers

p[0] <==> a[0]

* Operator can do , You can also do

 *a =25;

The array variable is const The pointer to , So it can't be assigned

int a[] <==> int *const a=..

原网站

版权声明
本文为[Today is also a day without baldness]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280517426043.html