Why can't I add anything to either keylist or locklist?Here's my code,
Code:
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include "key.h"
#include "lock.h"
#include "list.h"
/*Function prototypes*/
/*main*/
int main(void)
{
FILE * input = fopen("keys.txt" , "r");
FILE * input = fopen("locks.txt" , "r");
Key * inKey;
Key * outKey;
Lock * inLock;
Lock * outLock;
List * keyList = lst_new();
List * lockList = lst_new();
int numberofKeys;
int i;
fscanf(input, "d\n", &numberofKeys);
for(i = 0; i < numberofKeys; i++)
{
inKey = ky_read(input);
lst_add(keyList, inKey);
}
printf("No. of keys addded to list = %d\n\n", lst_size(keyList));
for(outKey = (Key*)lst_first(keyList);
outKey != NULL;
outKey = (Key *)lst_next(keyList))
{
printf("%d %s\n" , ky_getId(outKey), ky_getCode(outKey));
}
int numberofLocks;
int i;
fscanf(input, "d\n", &numberofLocks);
for(i = 0; i < numberofLocks; i++)
{
inLock = lc_read(input);
lst_add(lockList, inLock);
}
printf("No. of locks addded to list = %d\n\n", lst_size(lockList));
for(outLock = (Lock*)lst_first(lockList);
outLock != NULL;
outLock = (Lock *)lst_next(lockList))
{
printf("%d %s\n" , lc_getId(outLock), lc_getCode(outLock));
}