title: How to loop through a struct inside a struct while looping through the outer struct C Program
body: <p>Hi I am trying to create a structure inside a structure, the first structure will contain details for a number of students, the second structure will contain details of a number of modules from each student. Each time asking the user to input details for each student. I was able to create an instance of student structure called data and each time loop through each instance of data and scan in information for each student once only that worked for me. I am now trying to create another inside loop that will scan in a number of different modules that will assign these to each student. I am having problems with the second loop and would appreciate some guidance.</p>
  
  <pre><code>struct module{
  char moduleid[5];
  int credit;
  float grade;
  };
  
  //create structure student at includes a datatype
  //module
  
  struct student{
      char id[10];
      char fname[15];
      char lname[15];
      struct module results;
  };
  
  int main()
  {
      int i;
      int j;
      int numStuds;
      int numMods = 10;
  
  printf("Enter number of students\n");
  scanf("%d",&amp;numStuds);
  
  struct student data[numStuds]; //create an instance of structure student called data
  struct data.results mods[numMods];
  
  //input data
  for (i=0; i&lt;numStuds; i++){
  printf("PLEASE ENTER STUDENT DATA :\n\nID, FNAME AND LNAME\n");
  scanf("%s%s%s",data[i].id,data[i].fname,data[i].lname);
      for (j=0; j&lt;numMods; j++){
          printf("\nENTER MODULE DATA: \nMODULEID, CREDIT, GRADE :\n");
          scanf("%s%d%f",data[i].results.mods[j].moduleid,&amp;data[i].result.smods[j].credit,&amp;data[i].results.mods[j].grade);
          }
  }
  </code></pre>