当前位置:网站首页>Method of C language self defining function
Method of C language self defining function
2022-07-02 16:56:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
One 、C Call of custom function of language
1. Declare a custom function :
void fun(void);// Declaration of functions
You can also write custom functions before the main function ;
2. Call the user-defined function in the main function :
int main(void)
{
fun();// call fun function ;
return 0;
}
3. The function of writing custom functions :
void fun(void)
{
int a=12;
printf(“a=%d”,a); Output a
}
The source code is as follows :
#include "stdio.h"
void fun(void);// Declare custom functions
int main(void)// The main function
{
fun();// call fun function
“
return 0;
}
void fun(void)
{
int a=12;// Define an integer constant a=12;
printf("a=%d",a);// Output a;
}
shipment
Line program results :
a=12
Two 、 Functions with parameters
1, Declare a custom function :
void fun(uchar a);
2, Call function
int main(void)// The main function { int i; for(i=0;i<8;i++) { fun(i);// call fun function There must be parameters in brackets , Otherwise, an error will be reported printf(“\n”);// Line break }
return 0;
}
3. Write custom functions
void fun(char a)// fun The function takes a char Parameters of type { int i=0; char b=’*’; for(i=8;i>0;i–) printf(“%c”,b);// Output a; }
Source program :
#include "stdio.h"
void fun(char a);// Declare custom functions
int main(void)// The main function
{
int i;
for(i=0;i<8;i++)
{
fun(i);// call fun function
printf("\n");// Line break
}
return 0;
}
void fun(char a)
{
int i=0;
char b='*';
for(i=8;i>0;i--)
printf("%c",b);// Output a;
}
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/147813.html Link to the original text :https://javaforall.cn
边栏推荐
- [North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array
- Yyds dry goods inventory # look up at the sky | talk about the way and principle of capturing packets on the mobile terminal and how to prevent mitm
- System Verilog implements priority arbiter
- 机器学习-感知机模型
- How to solve the failure of printer driver installation of computer equipment
- 路由模式:hash和history模式
- john爆破出现Using default input encoding: UTF-8 Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
- Unity uses ugui to set a simple multi-level horizontal drop-down menu (no code required)
- PCL least median square method fitting plane
- Leetcode1380: lucky numbers in matrix
猜你喜欢
⌈ 2022 ⌋ how to use webp gracefully in projects
LeetCode 1. 两数之和
Headline | Asian control technology products are selected in the textile and clothing industry digital transformation solution key promotion directory of Textile Federation
PCL 点云镜像变换
Kubernetes three open interfaces first sight
Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP
Data security industry series Salon (III) | data security industry standard system construction theme Salon
Tech Talk 活动预告 | 基于Amazon KVS打造智能视觉产品
七一献礼:易鲸捷 “百日会战”完美收官 贵阳银行数据库提前封板
PCL point cloud image transformation
随机推荐
学习周刊-总第60期-2022年第25周
A week of short video platform 30W exposure, small magic push helps physical businesses turn losses into profits
Thinking about absolute truth and relative truth
基于多元时间序列对高考预测分析案例
Notice on holding a salon for young editors of scientific and Technological Journals -- the abilities and promotion strategies that young editors should have in the new era
Deep learning image data automatic annotation [easy to understand]
The login box of unity hub becomes too narrow to log in
入行数字IC验证后会做些什么?
TCP拥塞控制详解 | 2. 背景
LeetCode 6. Z 字形变换 (N字形变换)
Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP
电脑自带软件使图片底色变为透明(抠图白底)
LeetCode 3. Longest substring without duplicate characters
What will you do after digital IC Verification?
linux安装postgresql + patroni 集群问题
Cell:清华程功组揭示皮肤菌群的一种气味挥发物促进黄病毒感染宿主吸引蚊虫...
易语言abcd排序
john爆破出現Using default input encoding: UTF-8 Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
LeetCode 5. 最长回文子串
Typescript array out of order output