pound.c

来自「经典书籍:C Primer Plus(第五版)中文版和源代码 本书全面讲述了C」· C语言 代码 · 共 24 行

C
24
字号
/* pound.c -- defines a function with an argument   */
#include <stdio.h>
void pound(int n);   /* ANSI prototype              */

int main(void)
{
    int times = 5;
    char ch = '!';   /* ASCII code is 33            */
    float f = 6.0;

    pound(times);    /* int argument                */
    pound(ch);       /* char automatically -> int   */
    pound((int) f);  /* cast forces f -> int        */
  
    return 0;
}

void pound(int n)    /* ANSI-style function header  */
{                    /* says takes one int argument */
    while (n-- > 0)
        printf("#");
    printf("\n");
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?