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   
}

Starting somewhere for no particular reason:

arr[][STR_SIZE]; //is this legal for me to use?

It would be legal if you would have initialized arr, however since you didn't the compiler doesn't know how much space must set apart for arr.

arr[][STR_SIZE] = { "One", "Two", "Three" }; /* This would be OK */

typedef struct
{
  char social[9];
}SSN;
   
typedef struct
{
  int grade;
}GRADE;

Why to create a whole new data type structure for just one element inside?

int fillArray(FILE *inf, arr[]);

Not quite sure why you need to pass a pointer to a file handle. You are not doing anything with it inside the function.
arr is an array of arrays. You are just passing it as an array or string.

The easiest way is to prototype the multidimensional array the same way you declared
if arr[][STR_SIZE] then type_data function_name( arr[][STR_SIZE] );
if arr[MAX][MAX] then type_data function_name( arr[][MAX] );

scanf("%s", arr[i]); // is this the right way to fill an array or am i really wrong?

If you would have pass arr the proper way it would have a chance of being correct, other than scanf is not a good way of obtaining string data from user.
Search for fgets()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.