This code is suppose to read from an inputed file and then fill and array and sort the student records with in that file. Im having alot of trouble debugging myself and this program is due with in two days.
the input will look like
lastname, firstname grade ssn birthday date of first attendence
my main problem is mostly the coding from 46 to 78 i know i have mistakes but im a pretty new to c programming.
thanks
david
#include <stdio.h>
#include <string.h>
#define STR_SIZE 25
#define ARR_SIZE 10
#define MAX 25
typedef struct // structure that will be used in the program
{
char month [MAX];
int day;
int year;
}DATE;
typedef struct
{
char social[9];
}SSN;
typedef struct
{
int grade;
}GRADE;
typedef struct
{
char firstname[MAX];
char lastname[MAX];
DATE birthday;
SSN social[9];
GRADE stugrade;
}INFO;
int fillArray(FILE *inf, arr[STR_SIZE]); // to fill the array from a the file
void printArray(arr[], int numEls);// error messages are showing that there is problem before 'arr'
int main(int argc, char *argv[])
{
int numEls;
arr[][STR_SIZE]; //is this legal for me to use?
FILE *inf;
enum months {January = 1, February, March, April, May, June, July,
August, September, November, December};
enum months DateMonth;
SSN snum;
inf = fopen(argv[1], "r");
numEls = fillArray(inf, arr);
printArray(arr, numEls);
fclose(inf);
return 0;
}
int fillArray(FILE *inf, arr[]);
{
int i;
for (i = 0; i < STR_SIZE; i++)
scanf("%s", arr[i]);
}
void printArray(arr[], int numEls);
{
int i ;
for (i = 0; i < STR_SIZE; i++)
scanf("%s", arr[i]); // is this the right way to fill an array or am i really wrong?
}
void printArray(arr[], int numEls);
{
int i ;
for (i = 0; i < STR_SIZE; i++)
printf("Name: %s, %s Grade: %d SSN: %s DOB: %s %d, %d 1st Attend: %s %d, %d, ); // i know i still have to add the addresses for this to work
}