2012年11月4日

数据结构预热:跨函数使用内存

摘要: 1#include<stdio.h>2#include<malloc.h>34structStudent5{6intsid;7intage;8};9structStudent*creat(void);10voidshow(structStudent*);11intmain(void)12{13structStudent*ps;14ps=creat();15show(ps);16return0;17}18structStudent*creat(void)19{20structStudent*pst=(structStudent*)malloc(sizeof(structS 阅读全文

posted @ 2012-11-04 20:52 Your Song 阅读(158) 评论(0) 推荐(0) 编辑

数据结构预热:malloc动态分配内存

摘要: 1#include<stdio.h>2#include<malloc.h>34intmain(void)5{6intlen;7printf("输入数组的长度:len=");8scanf("%d",&len);9int*pArr=(int*)malloc(sizeof(int)*len);10for(inti=0;i<len;i++)11scanf("%d",pArr+i);//也可以写成&pArr[i];12for(i=0;i<len;i++)13printf("%d\n& 阅读全文

posted @ 2012-11-04 20:11 Your Song 阅读(443) 评论(0) 推荐(0) 编辑

数据结构,指针预热

摘要: 1#include<stdio.h>2voidf(int*p,intlen)3{4p[3]=10;//相当于*(P+3)5inti;6for(i=0;i<len;i++)7{8printf("%d\n",*(p+i));9}10}11intmain()12{13inta[]={1,2,3,4,5};14f(a,5);15printf("a[3]=%d\n",a[3]);1617return0;18} 阅读全文

posted @ 2012-11-04 11:01 Your Song 阅读(113) 评论(0) 推荐(0) 编辑

导航