如何改造这个程序
#include <stdio.h> typedef struct{ int month; int year; }DATE; int max(int x, int y); #define area(a, b) (a)*(b) double defaultPrice; int main() { defaultPrice=1000; printf("%d\n", area(2,4)); ... } int max(int x, int y){ return (x>y)?x:y; }
源文件与头文件的分离
module.h
typedef struct{ int month; int year; }DATE; int max(int x, int y); #define area(a, b) (a)*(b) double defaultPrice;
module.c
#include <stdio.h> #include "module.h" int max(int x, int y){ return (x>y)?x:y; } int main() { defaultPrice=1000; printf("%d\n", area(2,4)); return 0; }
时间: 2024-10-05 19:53:59