Dynamic memory allocation
Formal parameters of stack local variable function Heap dynamic memory allocation reference data type Static area global variable static variable
malloc and free
The pointer of void * type will be returned after successful development Failed to open. NULL returned The parameter is the size of the open space free(p) after reclaiming spa ...
Posted by MrXander on Sat, 11 Sep 2021 23:48:32 -0700
Custom data type
Structure (struct)
Definition of structure variables
#include<stdio.h>
#include<string.h>
#include<ctype.h>
struct MyStruct
{
char name[20];
int age;
}s4,s5,s6;//Create a global list of structure variables
//Create structure global variable
struct MyStruct s3;
//Anonymous structure
struct {
int st;
}st;//Anonymous stru ...
Posted by public-image on Sat, 11 Sep 2021 17:40:48 -0700
Understanding of pointers
1: Wrong use is not self-knowledge 2: Wrong export 3: Error resolution 4: Understanding and perception after solution
1: I believe everyone has heard of it, and I know it, and I also know the harm. But I don't know what I've been using is a wild pointer. I'm ashamed to say.
Use pointer before
//Function: read the contents in the pointer ...
Posted by hayson1991 on Fri, 10 Sep 2021 01:12:18 -0700
C language for multi-layer dynamic memory allocation, two-dimensional array
One-dimensional Array Dynamic Memory Allocation
First, let's start with a simple dynamic memory allocation.
#include "stdio.h"
#include "stdlib.h"
#define N 5
int main() {
int* arr = (int*)malloc(sizeof(int)*N);
for(int i = 0; i < N; i++) {
arr[i] = i * i;
}
for(int i = 0; i < N; i++) {
printf("\n% ...
Posted by Daniel Exe on Thu, 09 Sep 2021 10:14:12 -0700
[C language] stack and queue
The code in this paper is basically implemented by C language, except for the code implementation of "2.3.4 Leetcode496".
1. Queue
1.1 nature of queue
FIFO: first in, first out. The team goes out first and the team goes out at the end.
1.2 general queue
1.2.1 code implementation of ordinary queue
#include <stdio.h>
#includ ...
Posted by logicsound on Wed, 08 Sep 2021 01:45:14 -0700
PAT grade B exercise 1034 four operations of rational numbers
Title:
Enter two fractional rational numbers in the form of A1 / B1 and A2 / B2 in one line, where the numerator and denominator are all integers within the integer range, the negative sign can only appear in front of the numerator, and the denominator is not 0.
Output format:
Output the sum, difference, product and quotient of two rational ...
Posted by stopblackholes on Tue, 07 Sep 2021 13:36:26 -0700
Two-dimensional arrays and secondary pointers in function parameters
Two-dimensional arrays and secondary pointers in function parameters
Preface:
_Two-dimensional arrays are passed through a second-order pointer in a template function given by leetcode, which also gives an array of Row rows and Col columns. a[i][j] is often used directly in the function to traverse each element of the two-dimensional array.A ...
Posted by shak123 on Tue, 07 Sep 2021 09:45:01 -0700
Interprocess communication (IPC) mode
Interprocess communication (IPC) mode
Inter process communication (IPC) mainly includes the following:
1,Nameless pipe( PIPE)And famous pipes( FIFO).
2,Signal( signal).
3,system V-IPC Shared memory.
4,system V-IPC Message queue.
5,system V-IPC Semaphore.
6,Socket.
1. Pipeline
1.1 unknown pipeline
1.2 characteristics of unkn ...
Posted by trent2800 on Mon, 06 Sep 2021 20:12:34 -0700
PAT class a graph theory
Test site
1. Various deformations of Dijkstra 2. Connectivity, judging the number of connected blocks 3. Hierarchical traversal 4. Ergodic properties of edges
Foundation preparation - Dijkstra I
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 510;
int n, m;
int g[N][N];
...
Posted by shatner on Mon, 06 Sep 2021 12:33:50 -0700
Detailed explanation of C language operators and expressions
1. Operator classification:
1. Arithmetic operators + - * /% 2. Shift operator < < > > 3. Bit operator & |^ 4. Assignment operator = + = - = 5. Monocular operator sizeof! + + – 6. Relational operator > > = < < =! === 7. Logical operator & &|| 8. Conditional operator?: 9. Comma expression, 10. Subsc ...
Posted by NevadaSam on Mon, 06 Sep 2021 10:31:58 -0700