Thats my constants fileCode:#include <stdio.h> #include <stdlib.h> #include <string.h> #define TWOI 2 #define CLASS_SIZE 20 #define NAME_SIZE 20 #define ONEI 1 #define SALARY_SIZE 2 #define TEXT_BUFFER 81 #define ZEROI 0 struct employee { char *firstName; char *lastName; int id; char *class; double salary[SALARY_SIZE]; struct employee *nextEmployee; }; void hire(FILE **, char [], struct employee **); void printList(struct employee *);
This is part of my main program.Code:#include "hw3AndyFoxConstants.c" int main() { printf("hello"); struct employee *firstEmployee = NULL; FILE *infile; char lineOfText[NAME_SIZE] = {""}; infile = fopen("hw3AndyFoxInput.dat", "r"); fgets(lineOfText, NAME_SIZE, infile); while(!feof(infile)) { if(lineOfText[ZEROI] == '*') { switch(lineOfText[TWOI]) { case 'H': hire(&infile, lineOfText, &firstEmployee); printList(firstEmployee); break; case 'I': // initial(); break; case 'P': //promote(); break; case 'T': //transfer(); break; case 'E': //endOfData(); break; default: printf("Invalid input\n"); break; } } } return(ZEROI); }
I keep getting a seg fault over and over, the program wont even print the "hello" statement I put at the top of the main function. I have figured that if i comment out all the commands having to do with the input file it will print the hello. The program is working with a singularly linked list.



LinkBack URL
About LinkBacks



