Code · 1 file
Sample C Header File
C header files declare the types and functions that .c files implement. The C header sample is a small program — a customer record, a VIP check and a formatted total — that is the same in every language we offer, so you can compare them side by side.
C header · 353 B
Sample C header file
An idiomatic C header example: a customer record type, a VIP check, a total and a formatted loop — the same program in every language we offer.
CC0 · free for any use · Verified by an independent tool · Report a problem
/* Sample C header — samplefiles.com */
#ifndef SAMPLE_CUSTOMER_H
#define SAMPLE_CUSTOMER_H
#include <stddef.h>
#define VIP_THRESHOLD 10000.0
typedef struct {
int id;
const char *name;
double balance;
} Customer;
int is_vip(const Customer *c);
double total_balance(const Customer *customers, size_t n);
#endif /* SAMPLE_CUSTOMER_H */File details
Download from the command line
curl -L -o customer.h https://files.samplefiles.com/code/h/customer.hwget https://files.samplefiles.com/code/h/customer.hhttps://files.samplefiles.com/code/h/customer.hprintf '%s %s\n' 0e6339095958eb7321dff9d461dbfaa457329cb3ce386e5ba741c5cbf7f70dd9 customer.h | shasum -a 256 -cOr check the download in your browser with the checksum calculator.