Embedded driver engineer training notes (2)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.