grade-school: fix header declarions
This commit is contained in:
@@ -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<roster.count && GRADE(i)<=g; ++i) {
|
||||
for (i=0, j=0; i<roster.count && GRADE(i)<=g; ++i) {
|
||||
if (GRADE(i)==g)
|
||||
r.students[j++]=STD(i);
|
||||
}
|
||||
|
@@ -3,14 +3,12 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
//#include <stdbool.h>
|
||||
|
||||
#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
|
||||
|
Reference in New Issue
Block a user