/*C語言 將結構的值傳遞到函數裡*/
#include<stdio.h>
#include<stdlib.h>

struct data
{
    char name[10];
    int score;
};
//定義為全域結構

void function(struct data);
//宣告函數function()的原型

int main(void)
{
    struct data i = { "Tom", 87 };

    function(i);

    system("pause");
    return 0;
}

void function(struct data i)
{
    printf("Student name:%s\n", i.name);
    printf("Student score:%d\n", i.score);
}

結果為:

image

arrow
arrow
    創作者介紹
    創作者 愛學習 的頭像
    愛學習

    愛學習

    愛學習 發表在 痞客邦 留言(0) 人氣()