编程题:展示对整个结构体变量的引用的其他方法。功能:对整个结构体变量进行操作。#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(){char*string="Hello";printf("%s\n",string);}字符串指针变量的介绍:运行结果:
分类:
其他好文 时间:
2014-05-20 23:03:12
阅读次数:
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
编程题:指向二维数组元素的指针变量。功能:已知二维数组a[2][3],输入输出全部元素。#include<stdio.h>voidmain(){inta[2][3],i,j;int*p;/*用坐标法输入二维数组元素*/for(i=0;i<2;i++)for(j=0;j<3;j++)scanf("%d",&a[i][j]);/*用指针法输出二维数组元素*/p=a..
分类:
其他好文 时间:
2014-05-20 20:11:04
阅读次数:
343
#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>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
编程题:为枚举类型变量赋值。将整型值强制类型转换成枚举类型赋值#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
编程题:比较指向数组元素的指针变量和指向数组的指针变量的不同。#include<stdio.h>voidmain(){inta[2][3]={1,2,3,4,5,6};int*p1,(*p2)[3];/*p1指向数组元素,p2指向包含3个元素的一维数组*/p1=a[0];p2=a;/*用指向数组元素的指针变量输出二维数组元素*/for(;p1<a[0]+..
分类:
其他好文 时间:
2014-05-20 17:49:50
阅读次数:
217