C语言指针(三)指针传递给函数

来源:互联网 发布:ios 开发判断网络 编辑:程序博客网 时间:2024/04/29 01:04

实例1:传递一个无符号的long型指针给该函数

#include <stdio.h>#include <time.h> void getSeconds(unsigned long *par);int main (){   unsigned long sec;   getSeconds( &sec );   /* 输出实际值 */   printf("Number of seconds: %ld\n", sec );   return 0;}void getSeconds(unsigned long *par){   /* 获取当前的秒数 */   *par = time( NULL );   return;}
打印结果:

Number of seconds :1294450468

0 0