STM32——C语言课堂原代码
指针
/*
============================================================================
Name : Hello.c
Author :
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/ #include <stdio.h>
#include <stdlib.h>
void reset(int i);
void reset2(int* p);
void add_by_point(int x,int y,int *result);
int main(void) { printf("%d\n",sizeof(char));
printf("%d\n",sizeof(int));
int a = ;
int *p1 = &a;
char *p2 = p1; printf("%d\n",p1);
printf("%d\n",p2); printf("%d\n",*p1);//
printf("%d\n",*p2); puts("----------------------");
int c[] = {
,,,,
};
//数组内容值默认为0 (一组数组a定义10个变量,前5个分别是1,2,3,4,5,那么后六个默认为0)
printf("%d\n",c[]);
//数组名也是数字首地址(数组名的地址和首个数字的地址一样,比喻:一栋5层楼相当于一组数组,1层、2层、3层、4层、5层相当于变量的地址,那么的地址这栋楼的地址与第一层楼的地址一样。)
printf("%d\n",c);
//指针运算要根据指针的类型(int、float的字节是4个,char的字节是1个,i例如:int类型的a的地址是1,那么a+1的地址是5,如果a类型是char,则a+1的地址是2)
printf("%d\n",c+);
//
printf("%d\n",*(c+));//带*的是求地址里面的内容
*(c+) = ;
printf("%d\n",*(c+)); puts("----------------------");
int d = ;
reset(d);
//函数独立性
printf("%d\n",d);
reset2(&d);
//使用指针的方式突破函数壁垒
printf("%d\n",d); //什么是返回值
int e = add(,);
printf("e = %d\n",e);
int result = ;
//指针的方式计算结果
add_by_point(,,&result);
printf("result = %d\n",result); }
void reset(int i){
i = ;
}
void reset2(int* p){
*p = ;
} int add(int i,int j ){
/*
* 变量的生命周期
*
* */ int q = i+j;
return q;
} void add_by_point(int x,int y,int *result){
int r = (x + y);
*result = r;
}
/*
============================================================================
Name : hello.c
Author : lei
Version : 137
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/ #include <stdio.h>
#include <stdlib.h> int main(void) { main2();
return ;
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */ int i = ;
reset(i);
printf("%d\n",i);
reset2(&i);
printf("%d\n",i); int a = ;
int b = &a;
*(int*)b = ; printf("%d\n",a); int *p;
p=b;//p相当于(int*)b
*p = ;
printf("%d\n",a); /*
int c = 0x22336655;
int *d = &c;
*d = 1;
*/ char aa = ;
printf("%d\n",&aa); return EXIT_SUCCESS;
} void reset(int i){
i = ;
} void reset2(int *p){
*p = ;
}
http://download.csdn.net/album/detail/1111
枚举
/*
* meiju.c
*
* Created on: 2017年9月15日
* Author: Administrator
* 137
*/ enum COLOR {
RED,YELLOW,BLUE,GREEN
}; int favorate_color = RED;
void main2(){ puts("---------------------");
//枚举内容默认值从0开始,逐步加1
printf("%d\n",RED);
printf("%d\n",YELLOW);
printf("%d\n",BLUE);
puts("---------------------");
//枚举内容根据前面的那一个值加1
printf("%d\n",RED);
printf("%d\n",YELLOW);
printf("%d\n",BLUE); set_favorate_color(BLUE); printf("favorate_color = %d\n",favorate_color); } void set_favorate_color(int color){
favorate_color = color; }
机房内容
/*
============================================================================
Name : xu.c
Author : xu
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/ #include <stdio.h>
#include <stdlib.h> int main(void) {
puts("Hello UPC World"); /* prints Hello UPC World */
return EXIT_SUCCESS; int a = ;//定义变量a,赋值为1
int *p = &a;//定义一个指针,这个指针的内容是变量a的地址
*p = ;//*P是里面的内容,内容是变量a的地址,把1赋值给P*就是修改a的地址 int b = &b;//定义一个b变量,内容是b的地址
*(int*)b = ;//b是变量,(int*)b是把变量b强制转换为地址,*(int*)b是(int*)b地址的内容,也就是改变量b里面的内容 puts("----------------------");
enum COLOR {
red,bule=,yellow,green
};
//枚举的特性
} void reset1(int i)
{
i = ;
}
void reset2(int *i)
{
*i = ;
}
void reset3(int i)
{
*(int*)i = ; }
STM32——C语言课堂原代码的更多相关文章
- 20155308《信息安全系统设计基础 嵌入式C语言课堂考试补博客
20155308<信息安全系统设计基础 嵌入式C语言课堂考试补博客 知识点 置位 ?bits = bits | (1 << 7) ; /* sets bit 7 */ bits |= ...
- c++学习书籍推荐《面向对象程序设计:C++语言描述(原书第2版)》下载
百度云及其他网盘下载地址:点我 <面向对象程序设计:C++语言描述(原书第2版)>内容丰富,结构合理,写作风格严谨,深刻地论述了c++语言的面向对象编程的各种技术,主要内容包括:面向对象编 ...
- Java课程课堂作业代码
前言 本文章只是单纯记录课堂老师布置的课堂作业代码,题目都比较简单,所以没有写解题思路,相信大家都能理解,当然其中有的解法和代码不是最优的,当时只是为了完成题目,后来也懒得改了,如果有不恰当或者不正确 ...
- C语言课堂--现代编译环境搭建[2020年7月]
看过了很多专家吐槽目前的大学c语言教学问题多多: 教材难懂,消磨了学生的兴趣: 环境老旧,都2020了还有在用VC6甚至TurboC 2.0,语法不规范. 轮到自己上课,心想可不能再继续这样的c语言课 ...
- UWP开发之Template10实践:本地文件与照相机文件操作的MVVM实例(图文付原代码)
前面[UWP开发之Mvvmlight实践五:SuspensionManager中断挂起以及复原处理]章节已经提到过Template10,为了认识MvvmLight的区别特做了此实例. 原代码地址:ht ...
- 【伯乐在线】最值得阅读学习的 10 个 C 语言开源项目代码
原文出处: 平凡之路的博客 欢迎分享原创到伯乐头条 伯乐在线注:『阅读优秀代码是提高开发人员修为的一种捷径』http://t.cn/S4RGEz .之前@伯乐头条 曾发过一条微博:『C 语言进阶有 ...
- VS2015提示:未安装Style的Visual Studio语言支持,代码编辑Intellisense将不可用。服务器控件的标记Intellisense可能不起作用
一.问题 最近在VS2015打开文件,提示未安装Style的Visual Studio语言支持,代码编辑Intellisense将不可用.服务器控件的标记Intellisense可能不起作用. Int ...
- C语言学习书籍推荐《数据结构与算法分析:C语言描述(原书第2版)》下载
维斯 (作者), 冯舜玺 (译者) <数据结构与算法分析:C语言描述(原书第2版)>内容简介:书中详细介绍了当前流行的论题和新的变化,讨论了算法设计技巧,并在研究算法的性能.效率以及对运行 ...
- Arrays中toString 和 binarySearch 的原代码
只是记住方法是干什么的,但是对具体方法的理解还是不够 查找方法 当所查找的不存在的时候 返回值应该是 return -(low + 1); 一直知道toString 是转换成为字符串 但是具体的 ...
随机推荐
- The error may exist in com/bjpowernode/dao/StudentDao.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderExcept
The error may exist in com/bjpowernode/dao/StudentDao.xml### Cause: org.apache.ibatis.builder.Builde ...
- vue 引入Element组件
1.打开cmd,在当前目录中运行: npm i element-ui -S 2.src/main.js(红色的) import Vue from 'vue' import App from './Ap ...
- python requests 正则爬虫
代码: import requests from multiprocessing import Pool from requests.exceptions import RequestExceptio ...
- XAML绑定到资源文件字符串时失败
参考:https://stackoverflow.com/questions/19586401/error-in-binding-resource-string-with-a-view-in-wpf ...
- python---使用字典来实现链接表图
最后一章,坚持!!! # coding = utf-8 class Vertex: def __init__(self, key): self.id = key self.connected_to = ...
- 通过CSS自动截取字符串长度
Table Tr TD的自动换行 <style type="text/css"> table { width: 30em; table-layout: fixed; ...
- Temporal Action Detection with Structured Segment Networks (ssn)【转】
Action Recognition: 行为识别,视频分类,数据集为剪辑过的动作视频 Temporal Action Detection: 从未剪辑的视频,定位动作发生的区间,起始帧和终止帧并预测类别 ...
- 使用Filter跟踪Asp.net MVC页面加载(转)
转载地址:http://www.cnblogs.com/JustRun1983/p/4027929.html 最近,客户一直反馈系统使用慢,有时候能够指出具体是哪个页面,有时候又只是笼统地反馈慢.这种 ...
- python之集合set
1.测试 # python2和python3方法列表相同 ops23 = ['add', 'clear', 'copy', 'difference', 'difference_update', 'di ...
- net core体系-API-1Ocelot-(2)继续深入
简单的说Ocelot是一个用.NET Core实现并且开源的API网关技术.可能你又要问了,什么是API网关技术呢?Ocelot又有什么特别呢?我们又该如何集成到我们的asp.net core程序中呢 ...