Home >Backend Development >C#.Net Tutorial >c language function call example

c language function call example

angryTom
angryTomOriginal
2019-10-29 13:40:3112101browse

c language function call example

C language function call example

#include <stdio.h>
#define LABEL &#39;*&#39;
#define NAME "王五"
#define AGE 35

void printSplit(void);

int main()
{
    printSplit();
    printf("姓名:%s\n", NAME);
    printf("年龄:%d\n", AGE);
    printSplit();
    return 0;
}
void printSplit(void) {
    for (size_t i = 0; i < 10; i++)
    {
        putchar(&#39;*&#39;);
    }
    putchar(&#39;\n&#39;);
}

Note: The printSplit function is in the main function behind, so it needs to be declared in front.

Result:

**********
姓名:王五
年龄:35
**********

Function parameters

#include <stdio.h>
void printSplit(int);
int main()
{
    for (size_t i = 1; i < 10; i++)
    {
        printSplit(i);
    }
    return 0;
}
void printSplit(int width) {
    for (size_t i = 0; i < width; ++i)
    {
        putchar(&#39;*&#39;);
    }
    putchar(&#39;\n&#39;);
}

Result:

**
***
****
*****
******
*******
********
*********

Recommended course: C Language Tutorial

The above is the detailed content of c language function call example. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn