有如下代码,来分析了实参和形参:
#include <stdio.h>
#include <string.h>
#define NAME "dhjk‘lvfv;jkfdakvj"
#define ADDRESS "101 mEWKJF SJDFJ"
#defien PLACE "MOFDJGJG"
#define WIDTH 40
#define SPACE ‘ ‘
void show_n_char(char ch, int num);
int main(void)
{
int spaces;
show_n_char(‘*‘, WIDTH);
putchar(‘\n‘);
spaces = (WIDTH - strlen(ADDRESS)) / 2;
show_n_char(SPACE,spaces);
show_n_char(SPACE,(WIDTH - strlen(PLACE)) / 2);
show_n_char( ‘ * ‘ ,WIDTH);
return 0;
}
void show_n_char(char ch, int num)
{
int count;;
for(count = 1; count <= num; count++)
putchar(ch);
}
在以上的函数void show_n_char(char ch, int num)中,变量char ch,和int num都叫形式参量,他会被main主函数中的参数代替,
main函数中代替的参数叫做实际参数;
时间: 2024-11-08 03:45:02