Home >Backend Development >C#.Net Tutorial >c language function call example
C language function call example子
#include <stdio.h> #define LABEL '*' #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('*'); } putchar('\n'); }
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('*'); } putchar('\n'); }
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!