From 01365f370b6ca572b6ccf41f9446920779c1e257 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Wed, 18 Aug 2021 22:05:42 +0200 Subject: [PATCH] grade-school: fix header declarions --- c/grade-school/src/grade_school.c | 11 +++++------ c/grade-school/src/grade_school.h | 12 +++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/c/grade-school/src/grade_school.c b/c/grade-school/src/grade_school.c index 1044f04..2989826 100644 --- a/c/grade-school/src/grade_school.c +++ b/c/grade-school/src/grade_school.c @@ -16,10 +16,9 @@ void clear_roster() /* testing program expects bool here, but I prefer to return students count, * it makes more sense for me. */ -int add_student(char *s, uint8_t g) +int add_student(const char *s, const uint8_t g) { - int c=roster.count; - int i; + int c=roster.count, i; if (c >= MAX_STUDENTS) return 0; @@ -37,12 +36,12 @@ int add_student(char *s, uint8_t g) /* to avoid this everytime, we could build up one roster per grade while * adding students, but really overkill here. */ -roster_t get_grade(uint8_t g) +roster_t get_grade(const uint8_t g) { roster_t r; - unsigned i, j=0; + unsigned i, j; - for (i=0; i #include -//#include -#define MAX_NAME_LENGTH 20 #define MAX_STUDENTS 20 typedef struct student_s { uint8_t grade; - char *name; + const char *name; } student_t; typedef struct { @@ -18,10 +16,10 @@ typedef struct { student_t students[MAX_STUDENTS]; } roster_t; -void clear_roster(); -int add_student(char *, uint8_t); -roster_t get_grade(uint8_t); -roster_t get_roster(); +void clear_roster(void); +int add_student(const char *student, const uint8_t grade); +roster_t get_grade(const uint8_t grade); +roster_t get_roster(void); /* See GNUmakefile below for explanation * https://github.com/braoult/exercism/blob/master/c/templates/GNUmakefile