I. C language code specification
1. A blank line is required between the pre-processing code and the main function code.
2. A blank row is required for memory allocation and processing.
3. Pay attention to indentation when writing code. Good at using the tab key.
II. Introduction to the structure of von noiman
It consists of the memory, controller, memory, input device, and output device.
Memory refers to memory rather than hard disk. Therefore, the data to be processed by the CPU goes through the memory.
Iii. Core of C language: Memory Diagram
For embedded development, the C language is more about memory operations. Therefore, the understanding of memory is very important. To write a program, you must learn to draw a memory graph to identify how data or code is allocated in the memory.
We operate on a virtual memory constant of 4 GB;
IV. C language basics
Three structures: Sequence Structure, select structure, and cyclic structure. Any logic can be expressed in these three structures.
Select structure:
If... else, the two are a pair of else. If
Loop Structure
For do... while () while can represent each other.
Programs Written in the classroom and after-school:
Judge whether the calculation result is "accumulated" or "binary number in decimal form". Fast sorting (not complete). Hundreds of chicken. Problem: daffodils. monkeys eat peach. Maximum common number and minimum common number.
Some code:
Daffodils
Hundreds of dollars
#include<stdio.h>int main(){ int a ,b ; for(a=0;a<33;a++) for(b=0;b<300;b++) if((a*3+(float)b/3) == 100) if((a+b)==100) printf("100钱可以买%d只大鸡,%d只小鸡\n",a,b);}~
Hundreds of chickens and hundreds of dollars
#include<stdio.h>int main(){ int i ; int sum = 1; for(i = 1; i<5; i++) { sum = (sum+1)*2; } printf("猴子一共吃了 %d只桃子\n",sum);}~ ~
Monkeys eat peach
Embedded driver engineer training notes (2)