c语言里所有以#开头的都是预编译指令,就是在正式编译之前,让编译器做一些预处理的工作。
#ifdef DEBUG printf("variable x has value = %d\n",x);
#endif#if和#endif是配对的,叫做条件编译指令,如果满足#if后面的条件,就编译#if和#....
分类:
其他好文 时间:
2014-05-22 04:37:10
阅读次数:
251
RCC CSR寄存器会存储复位标示,可通过它来知道复位原因,来源: 1
if(RCC_GetFlagStatus(RCC_FLAG_PINRST)) 2 printf("PINRST\r\n"); 3
if(RCC_GetFlagStatus(RCC_FLAG_PORR...
分类:
其他好文 时间:
2014-05-22 03:16:49
阅读次数:
3604
一、三道考题开讲之前,我先请你做三道题目。(嘿嘿,得先把你的头脑搞昏才行……唉呀,谁扔我鸡蛋?)考题一,程序代码如下:void Exchg1(int x,
int y){ int tmp; tmp = x; x = y; y = tmp; printf("x = %d, y = %d\n", x, ...
分类:
编程语言 时间:
2014-05-22 02:09:24
阅读次数:
213
编程题:输入一串字符,程序会自动将大写字母转换为小写#include<stdio.h>#include<conio.h>main(){ inti=0; chara[50],ch; printf("输入一串字符,程序会自动将大写字母转换为小写\n"); printf("按任意键继续,按Esc键退出\n"); while(ch=getch()!=27) { fflush(..
分类:
其他好文 时间:
2014-05-21 02:46:26
阅读次数:
277
编程题:引用共用体变量的成员#include<stdio.h>voidmain(){uniontemp{chara;intb;}t;t.a=66;t.b=266;/*266=256+10即266的二进制为100001010,所以高字节放低字节放10*/printf("%x:%d,%x:%d\n",&t.a,t.a,&t.b,t.b);}分析代码的算法:运行结果:
分类:
其他好文 时间:
2014-05-20 22:44:14
阅读次数:
388
编程题:枚举变量作为循环控制变量#include<stdio.h>voidmain(){enumseason{spring=1,summer,autumn,winter}s;for(s=spring;s<=winter;s++) printf("%d\n",s);}
分类:
其他好文 时间:
2014-05-20 21:27:05
阅读次数:
357
#include<stdio.h>voidmain(){enumseason{spring=1,summer,autumn,winter}s;for(s=spring;s<=winter;s++) printf("%d\n",s);}
分类:
其他好文 时间:
2014-05-20 19:49:00
阅读次数:
315
编程题:指针变量指向结构体数组。#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>#include<conio.h>fun(intm,char*s){charc;intk,i=10;while(m!=0){k=m%i;*s=k+‘0‘;s++;m=(m-k)/i;}*s=‘\0‘;}main(){intn;chars[81],*p;p=s;printf("enteranumber(>100):");scanf("%d",&n);fun(n,s);p..
分类:
其他好文 时间:
2014-05-20 17:59:19
阅读次数:
232
编程题:为枚举类型变量赋值。将整型值强制类型转换成枚举类型赋值#include<stdio.h>voidmain(){enumseason{spring,summer,autumn,winter}s1,s2;s1=summer;s2=(enumseason)2;printf("s1=%d,s2=%d\n",s1,s2);}
分类:
其他好文 时间:
2014-05-20 17:51:10
阅读次数:
224