There are a number of subtle issues with your code, the first and foremost -- Why in the world do you want a 2D array of structs when a simple array makes much more sense?? Regardless, you are free to use a 2D array, but as far as your problem statement goes -- there is absolutely no need to do so.
Using a simple 1D array greatly simplifies your code, as well as the passing of parameters between functions. Give the following a try for comparison:
#include <stdio.h>
typedef struct student {
int ID;
int classNum;
} student;
#define NSTUD 20
student *makeClass (student *classroom);
int main (void) {
student classroom [NSTUD] = {{0}, {0}}; /* array of 20 students */
size_t i = 0;
makeClass (classroom);
printf ("\nclassroom information:\n\n");
for (i = 0; i < NSTUD; i++)
printf (" ID : %2d classNum : %2d\n",
classroom[i].ID, classroom[i].classNum);
return 0;
}
/* function that will return the array */
student *makeClass (student *classroom)
{
if (!classroom) return NULL; /* validate classroom address */
int classNumba = 30;
int x = 0;
for(x = 0; x < NSTUD; x++)
{
classroom[x].ID = x + 1;
classroom[x].classNum = classNumba;
classNumba++;
}
return classroom;
}
Compile (with Warnings enabled)
gcc -Wall -Wextra -O3 -o bin/classroom classroom.c
Use/Output
$ ./bin/classroom
classroom information:
ID : 1 classNum : 30
ID : 2 classNum : 31
ID : 3 classNum : 32
ID : 4 classNum : 33
ID : 5 classNum : 34
ID : 6 classNum : 35
ID : 7 classNum : 36
ID : 8 classNum : 37
ID : 9 classNum : 38
ID : 10 classNum : 39
ID : 11 classNum : 40
ID : 12 classNum : 41
ID : 13 classNum : 42
ID : 14 classNum : 43
ID : 15 classNum : 44
ID : 16 classNum : 45
ID : 17 classNum : 46
ID : 18 classNum : 47
ID : 19 classNum : 48
ID : 20 classNum : 49
Like I said, you are free to use a 2D array. If there is a valid reason for it, then it may make sense, but based upon what I can see in your questions, you are much better served with a 1D array. Let me know if you have any questions.