在 Linux 内核代码,特别是驱动代码中经常见到的用法是使用一个标准结构,后面的代码基于这个结构来实现,类似面向对象的多态特性。
在 C 语言里面借助结构体和函数指针实现的这个功能,这里我们写了个例子,提取了关键代码:
#include
struct s_new{
char name[10];
char* (* my_method)(char *name);...
分类:
系统相关 时间:
2014-05-23 07:58:18
阅读次数:
324
Football Score
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2579 Accepted Submission(s): 729
Problem Description
Football is on...
分类:
其他好文 时间:
2014-05-22 12:45:13
阅读次数:
291
#include
#include
#include
#include
#include
using namespace std;
struct Library
{
long number;//编号
string bookname;//书名
string author;//作者
string press;//出版社
int price;//价格
}...
分类:
其他好文 时间:
2014-05-22 07:17:38
阅读次数:
206
OK,继续上篇的内容. 配置好外部中断源以后, 就得使能外部中断线了.
为了方便看再借下这个图:
对外部中断的使能其实就是配置上面这些寄存器.即使能哪EXIT线,选择上面模式,是中断还是事件,选择下降沿还是上升沿.
具体怎么写寄存器这就不研究了, = = 太麻烦了.. 直接用STM32的库就行了,来看看它的代码吧
这是EXTI结构体的初始化函数,
void EXTI_Struct...
分类:
其他好文 时间:
2014-05-22 06:43:16
阅读次数:
395
结构的定义定义一个结构的一般形式为:struct结构名{成员表列}例如:struct
stu{int num;char name[20];int
age;}结构类型变量的说明结构体定义并不是定义一个变量,而是定义了一种数据类型,这种类型是你定义的,它可以和语言本身所自有的简单数据类型一样使用(如in...
分类:
其他好文 时间:
2014-05-22 05:36:40
阅读次数:
172
笔试遇到很多sizeof的小题,博主基础堪忧,怒总结如下,还是要巩固基础啊啊啊!sizeof操作符
对象所占内存空间的大小,单位是字节关键词:char 数组 指针 结构体sizeof(NULL)
结果为11.基本类型占内存大小32位机64位机器类型字节数int4char1指针48float4浮点型l...
分类:
编程语言 时间:
2014-05-22 04:55:18
阅读次数:
299
编程题:展示对整个结构体变量的引用的其他方法。功能:对整个结构体变量进行操作。#include<stdio.h>voidmain(){structperson{charname[20];charsex;structdate {intyear; intmonth; intday; }birthday; floatheight;}per1,per2={"LiPing","M",2013,12,15,175.5};per1=p..
分类:
其他好文 时间:
2014-05-21 00:20:43
阅读次数:
249
编程题:结构体数组的引用。功能:输出结构体数组各元素的成员值#include<stdio.h>voidmain(){structperson{charname[20];charsex;intage;floatheight;}per[3]={{"LiPing",‘M‘,20,175},{"WangLing",‘F‘,19,162.5},{"ZhaoHui",‘M‘,20,178}};inti;for(i=0;i<3;i++)print..
分类:
其他好文 时间:
2014-05-20 21:31:06
阅读次数:
336
编程题:指针变量指向结构体数组。#include<stdio.h>voidmain(){structperson{charname[20];charsex;intage;floatheight;}per[3]={{"LiPing",‘M‘,20,175},{"WangLing",‘F‘,19,162.5},{"ZhaoHui",‘M‘,20,178}};structperson*p;for(p=per;p<per+3;p++)printf("%-18s%3c%..
分类:
其他好文 时间:
2014-05-20 18:57:32
阅读次数:
255
编程题:对结构体变量中成员的引用展示。#include<stdio.h>voidmain(){structperson{charname[20];charsex;structdate {intyear; intmonth; intday; }birthday; floatheight;}per;printf("Enterthename:");gets(per.name);per.sex=‘M‘;per.birthday.year=2013;per.birthd..
分类:
其他好文 时间:
2014-05-20 18:41:16
阅读次数:
360