函数的返回值是void

//  main.c
//  test
//
//  Created by mac on 2019/4/9.
//  Copyright © 2019年 mac. All rights reserved.

#include <stdio.h>

void sub(int x,int y,int z){
    z=y-x;
}

void main() {
    int a=1,b=2,c=3;
    sub(10,5,a);
    sub(8,a,b);
    sub(a,b,c);
    printf("%d%d%d",a,b,c);
}

输出结果

123Program ended with exit code: 3

Tips

  • 虽然sub函数的返回类型是void,但是程序本身不会报错,而且还有返回结果。

猜你喜欢

转载自www.cnblogs.com/overlows/p/10676612.html