当前位置:网站首页>2022.1.25
2022.1.25
2022-06-25 05:16:00 【LF19971222】
‘a’, The return is a From .
“a”,a The character constant of .
General format for array definitions :
type Array name [ Subscript 1][ Subscript 2].....[ Subscript n]
among , The type is the base type of the array element , That is, the type of each element . Subscript value n Expressed as the number of array elements in place , The upper bound of the array subscript of this dimension is n-1;C The subscript lower bound of an array is always 0. Dimension is the number of subscripts .
The definition of one-dimensional array :
type Array name [ Constant expression ];
Int a[10]
Define a 10 One dimensional array of integer elements .
Element is :a[0]、a[1]、....a[9]
- The array name definition rule is the same as the variable name , Follow the identifier definition rules
- A constant expression enclosed in square brackets after the array name , You can't use parentheses
- The constant expression represents the number of elements , That is, array length , Not the upper bound of the array
- Constant expressions can include symbolic constants of constants , Variables cannot be included .
- Array must be defined first , And then use .
- The arrangement order of one-dimensional array elements in memory is linear, that is, continuous storage .
C Specify that only the elements of the array can be referenced one by one , Instead of applying the entire array at once .
An array element is actually a variable name , Array elements are used as variables .
Initialization of one dimensional array :
- When defining an array , Assign initial values to array elements .
- You can give only a few elements an initial value .
Int a[10]={0,1,2,3,4}
3、 If you want an array to be all values n, for :int a[10]={0,0,0,0,0,0,0,0,0,0}
4、 When assigning initial values to all array elements , You can not specify the array length .
for example :int a[]={1,2,3,4,5}
- When an array is specified as a static storage type or an external storage type , If the initial value is not displayed , The array elements are automatically initialized to... During the program compilation phase 0.
Initialization of 2D array
- Branch to initial value of two-dimensional array
- You can also write all the data in a curly bracket , Assign values to each element in the storage order of the array .
- You can assign initial values to some elements . You can also assign a value to an element in the array .
- You can also assign initial values to some elements .
int a[3][4]={ {1},{},{5,6}};
One dimensional array name as function parameter
Use simple variables as function parameters , Can pass a data from an argument to a formal parameter . Use the array name as the function parameter , For address calls, the calling function can pass the first address of the array to the called function , And it can transfer multiple data from the called function to the calling function .
Array names as function arguments
delivery : It belongs to address calling , Pass the first address of the real parameter group to the virtual parameter , The virtual parameter is also an array name .
Virtual parameter requires : Must be an array name .
Argument requirements : Can be another array name .
Combination of dumb and solid : Dummy arrays have the same first address , The first element of the dummy array occupies the same storage unit , After that, the elements are combined one by one in order .
Function pass value ( Array name ) Sketch Map

1、 When using array names as function parameters , The array should be defined in the main function and the called function respectively -- Argument array 、 Parameter array .
2、 The size of the parameter array declared in the called function n, It doesn't actually work , because C The compiler does not check the size of the shape parameter group , Only the first address of the argument is passed to the formal parameter array .
3、 Arguments and formal parameters can have the same or different names , Their array names represent the first address of the array .
4、 If the called function changes the element value of the formal parameter array , Then the element values in the real parameter group will also change . Note that this change is not caused by formal parameters being passed to arguments (C The language does not allow this reverse value to be passed ), It is caused by the fact that two arrays of formal and actual parameters share the same memory because they point to the same address in memory .
Definition of character array
Format :char Array name [ constant 1][ constant 2]......;
Initialization of character array :
- Assign each element in the array character by character
- The number of initial values in curly braces is greater than the length of the array , According to the syntax error processing
- For example, the number of initial values is less than the length of the array , Only those characters are assigned to the first elements in the array , The rest of the elements are automatically set to empty characters .
- For example, the number of initial values is equal to the length of the array , The array length can be omitted in the definition , The system will automatically determine the array length according to the number of initial values .
String and string end flag :“\0”
Use a loop to input and output character by character :%c, You must enter the corresponding number .
Input and output the whole string at one time :%s, Enter the desired number and press enter .
Puts and gets Function can only enter one at a time .
A variable has two values , One address value, one content value .
example *p
*p Is a pointer , Refers to the address .
p It's a pointer variable , Refers to the variable that stores the address .
The type of the pointer refers to the type of the variable pointed to by the pointer .
Pointer properties are defined by * Stated .
Define... In the statement * No. is just a description of the role , The execution of a statement is the retrieval of the content .
边栏推荐
- Handwritten promise all
- SQL lab range explanation
- Swift rapid development
- Ranorex Studio 10.1 Crack
- buuctf web
- 2021-03-23
- Google Earth engine (GEE) - Global jrc/gsw1_ 1 / batch download of yearlyhistory dataset (China region)
- How PHP gets the user's City
- Two dimensional array and function call cases of C language
- C style string
猜你喜欢

hr竟主动给这位测试小姐姐涨工资,她是怎么做到的?

Penetration test - directory traversal vulnerability

Example of dynamic programming 3 leetcode 55

How to install the blue lake plug-in to support Photoshop CC 2017

Route parameters to jump to the page and transfer parameters -- > hidden parameter list

What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect

DOM document object model (I)

Svg code snippet of loading animation

Create an environment for new projects

buuctf(re)
随机推荐
API interface management setup -eolinker4.0
WPF uses Maui's self drawing logic
SRC platform summary
How to download and use Xiaobai one click reload on the official website
CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)
[keil] GPIO output macro definition of aducm4050 official library
Swift rapid development
Reading and writing of nodejs excel (.Xlsx) files
Create an environment for new projects
Precise delay based on Cortex-M3 and M4 (systick delay of system timer can be used for STM32, aducm4050, etc.)
Basic knowledge of web pages (URL related)
Electronic Society C language level 1 28, character diamond
Apache+php uploading large files
Conflict between v-mode and v-decorator in Ant Design
JS verification code input number auto skip
Keyboard key code value
dotnet-exec 0.4.0 released
Essais de pénétration - sujets d'autorisation
Dynamic programming example 1 leetcode 322 coin change
Jason learning