c language function call example

angryTom
Release: 2019-10-29 13:40:31
Original
12062 people have browsed it

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;);
}
Copy after login

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

Result:

**********
姓名:王五
年龄:35
**********
Copy after login

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;);
}
Copy after login

Result:

**
***
****
*****
******
*******
********
*********
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template