okay well i made them all unsigned ints but i am having issues with the fwrite statement:
Code:
#include <stdio.h>
#include <stdlib.h>
#include "student.h"
void addStudent(){
student tmp;
char tmper, dummy[80];
FILE *FILE_PTR;
FILE_PTR = fopen(FILE_NAME,"ab+");
printf("Please enter their 9-digit id number: ");
scanf("%d", &tmp.idNumber);
printf("\nPlease enter their name: ");
fgets(dummy, sizeof(dummy), stdin);
gets(tmp.name);
printf("\nPlease enter their class level: ");
fgets(dummy, sizeof(dummy), stdin);
scanf("%c", &tmper);
tmp.classLvl = tmper;
printf("\nPlease enter their gender: ");
scanf("%c", &tmper);
tmp.gender = tmper;
printf("\nPlease enter their age: ");
scanf("%d", &tmp.age);
fwrite(&tmp, sizeof(student), 1, FILE_PTR);//error's here
fclose(FILE_PTR);
}//end addStudent
and here is the revised header file:
Code:
#include <stdio.h>
#include <stdlib.h>
#define FILE_NAME "~/CSC60/lab5/out.txt"
#define MAX_SIZE 29
#define SIZE 3
typedef struct {
unsigned int idNumber;
unsigned char name[MAX_SIZE],testScore[SIZE], programScore[SIZE];
unsigned char age;
unsigned int classLvl : 3, gender : 1;
}student;
void addStudent();
void deleteStudent(unsigned int);
void addTestScore(unsigned int);
void addProgramScore(unsigned int);
void outputClassReport();
it seems to not like my fwrite line i tried it both with a pointer and with a regular struc assignment and not a structure pointer and it will all error on this line..