'Trying to create a loop that has an array continuously add data within it that the user creates

I just want to quickly note that im a third semester CS student so im fairly new to C and I just really want help on a project im creating for myself.

Okay so basically im trying to have it so that I create a question that the code asks the user such as "Type in your name, age, and house" (im trying to create this harry potter quiz for my gf). So I want to store the user information within an array inside of this structure I created. I want it so that the user puts down their information and it stores it in the structure and then later the user can add another person to compare their results to and itll store this users data as well and whenever you want to print it all itll print it. Im hoping this makes sense so please feel free to ask questions but ill

#include<stdio.h>
#include <stdlib.h>
#include "sortinghatquiz.h"


#define maxNum 100



int main_sorting_quiz()
{
    sorting_hat_menu();
    sorting_hat_switch();
}

int sorting_hat_menu()
{
    char array[]={"."};
    for (int i = 0; i < 50; i++)
    {
        printf("%c\n", array[0]);
    }
    printf("\n\n\t\t\tWelcome to the Hogwarts Sorting Hat Quiz!!!\n");
    printf("\t\t\t________________________________________\n");
    printf("\t\t\t1 - Start the quiz!\n\t\t\t2 - Find Existing Quiz!\n\t\t\t3 - Compare results with another user!\n\t\t\t4 - Return to main menu!\n\n");
}

int sorting_hat_switch()
{
    int choice_quiz,x;
    printf("\n\t\t\tChoose your option: ");
    scanf("%d", &choice_quiz);
    switch (choice_quiz)
    {
    case 1:
        start_quiz(x);
        break;
    case 2:
        find_quiz();
        break;
    case 3:
        compare_results();
        break;
    default:
        break;
    }
}


int start_quiz(quizinfo *i)
{
    quizinfo A[maxNum] = {};
    for (i = 0; i < 4; i++)
    {
        start_quiz_menu(i);
        return i;
    }
    printf("\nHeres the first persons data %s, %s, %s\n", A[0].name, A[0].age, A[0].house);
    printf("\nHeres the second persons data %s, %s, %s\n", A[1].name, A[1].age, A[1].house);
    printf("\nHeres the third persons data %s, %s, %s\n", A[2].name, A[2].age, A[2].house);
    printf("\nHeres the fourth persons data %s, %s, %s\n", A[3].name, A[3].age, A[3].house);  
    //Type in your name
    //Type in your age
    //Type in your desired house (this wont influence your decision)
    //All of this data needs to be stored within structure

}
int start_quiz_menu(quizinfo *x)
{
    int i;
    quizinfo A[maxNum] = {};
    printf("\t\t\tType your name in: ");
    scanf("%s", A[i].name);
    printf("\n\t\t\tType in your age: ");
    scanf("%s", A[i].age);
    printf("\n\t\t\tType in your desired house to see if you think you know yourself: ");
    scanf("%s", A[i].house);
    printf("\n\n\t\t\tHello %s, at the age of %s you have begun your quest to see which hogwarts house you are placed in.\n\t\t\tLets see if %s really is your true house.....\n", A[i].name, A[i].age, A[i].house); 
}

int find_quiz()
{
    printf("Find Quiz Test 1");
}

int compare_results()
{
    printf("Compare results Test 1");
}

Im experimenting with libraries so its all connected and compiled into one main.c file so heres the .h file for this piece of code

#ifndef _SORTINGHATQUIZ_H_
#define _SORTINGHATQUIZ_H_

typedef struct 
{
    char name[100];
    int age[10];
    char house[100]
}quizinfo;

int main_sorting_quiz();
int sorting_hat_menu();
int start_quiz(quizinfo *i);
int start_quiz_menu(quizinfo *x);
int find_quiz();
int compare_results();


#endif

Also like I said, im fairly new to this so If theres anything I can optimize to make more efficient then I would love to hear some advice. Thanks!

c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source