c语言结构体定义以及引用

#include "stdio.h"
#include "string.h"
#include "stdlib.h"

struct  Transaction{
char product[20];
int qualtity;
float unit_price;
float total_amount;
};
struct Transaction *current_transaction;
struct Transaction current_tran;
void compute_total_amount(struct Transaction *);

void main()
{
current_transaction = malloc(sizeof(struct Transaction));
printf("input qualtity\n");
scanf("%d",&current_transaction->qualtity);
printf("input unit_price\n");
scanf("%f",&current_transaction->unit_price);
compute_total_amount(current_transaction);
printf("%f\n",current_transaction->total_amount);
}


void compute_total_amount (struct Transaction *trans)
{
 trans->total_amount = trans->qualtity * trans->unit_price;
}

你可能感兴趣的:(struct,C语言,结构)