42 lines
773 B
C
42 lines
773 B
C
#include "namesarchive.h"
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static char names[MAX_NAMES][MAX_NAME_LEN+1];
|
|
static unsigned int numberOfEntries = 0;
|
|
|
|
/*
|
|
static void cpy(char *dst, const char *src, unsigned int max)
|
|
{
|
|
int i;
|
|
for(i = 0; i < max && *src != '\0'; i++)
|
|
{
|
|
*dst = *src;
|
|
dst++;
|
|
src++;
|
|
}
|
|
if(i < max)
|
|
*dst = '\0';
|
|
}*/
|
|
|
|
int addName(const char *name)
|
|
{
|
|
if(numberOfEntries < MAX_NAMES)
|
|
{
|
|
strncpy(names[numberOfEntries], name, MAX_NAME_LEN+1);
|
|
names[numberOfEntries][MAX_NAME_LEN] = '\0';
|
|
numberOfEntries++;
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void printNames()
|
|
{
|
|
for(int i = 0; i < numberOfEntries; i++)
|
|
{
|
|
printf("%s\n", names[i]);
|
|
}
|
|
} |