Skip to content

Instantly share code, notes, and snippets.

@adcar
Created February 20, 2020 19:59
Show Gist options
  • Save adcar/edcf5bb4e3a24d3654b51da96359eeb1 to your computer and use it in GitHub Desktop.
Save adcar/edcf5bb4e3a24d3654b51da96359eeb1 to your computer and use it in GitHub Desktop.
employee
GNU nano 4.8 employee.c
#include <stdio.h>
#include <locale.h>
struct Employee {
char * name;
int yearBorn;
int salary;
int ssn[9];
};
void printEmployee(struct Employee e);
struct Employee e = {"Jason", 1985, 50000, {1, 2, 3, 4, 5, 6, 7, 8, 9}};
int main() {
// https://stackoverflow.com/a/11695246/6501208
setlocale(LC_NUMERIC, "");
printEmployee(e);
}
void printEmployee(struct Employee e) {
printf("Name: %s, DOB: %d, SSN: %d%d%d-%d%d-%d%d%d%d\n", e.name, e.yearBorn,
e.ssn[0], e.ssn[1], e.ssn[2], e.ssn[3], e.ssn[4], e.ssn[5], e.ssn[6], e.ssn[7], e.ssn[8]);
printf("Salary: $%'d\n", e.salary);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment