C程序设计语言(K&R)学习笔记--7.include,define,ifndef综合应用demo

来源:互联网 发布:mac steam dota2 国服 编辑:程序博客网 时间:2024/06/06 11:48

mycommon.h

enum boolean {false,true} status,flag;void printIntArray(int *p,int len,int isPrint){int i;if(isPrint){for(i=0;i<len;i++,p++){printf("%d\t",*p);}}printf("\n");}

test.c

#ifndef MYCOMM_FUNTION_A    #define MYCOMM_FUNTION_A #include <stdio.h>#include "mycommon.h"#include "test1.c"#endifvoid main(){int a[]={1,2,3,4,5};printIntArray(a,5,true);add(a,5);}

test1.c

#ifndef MYCOMM_FUNTION_A    #define MYCOMM_FUNTION_A#include <stdio.h>#include "mycommon.h"#endifvoid add(int *p,int len){printIntArray(p,len,false);}


0 0
原创粉丝点击