/*構造体を定義して、単語カード1枚分のデータを表示するだけ*/
#include <stdio.h>
#include <string.h>

#define MAX_WORDS 100 /*単語カードを最大何枚まで保存できるか*/

typedef struct {
	char word[50]; /*word:[50]はこの配列が何文字分の箱を持つかを表す*/
	char meaning[100]; /*char word[50]はchar1文字を50個並べた箱(配列)を用意するという意味*/
	char example[200];
	char category[20];
	int correct_count;
	int wrong_count;
} WordCard; /*新しい単語カードを1枚追加する関数*/

        void add_words(WordCard cards[], int *count){
            if (*count >= MAX_WORDS) { /* *countは、int型の値が**どこにあるか(アドレス)**を受け取る*/
                printf("Unavale to add a new word(Max words%d)\n", MAX_WORDS);
                return;
            } /*cards: カードの配列(呼び出し元の配列を直接操作する)
            cards: カードの配列(呼び出し元の配列を直接操作する)*/
            
            WordCard new_card;
            printf("Word :");
            fgets(new_card.word, sizeof(new_card.word), stdin);
            new_card.word[strcspn(new_card.word,"\n")] = '\0';
            /* fgetsはfile get string(ファイルから文字列を取得する)の略*/
            printf("Meaning :");
            fgets(new_card.meaning, sizeof(new_card.meaning), stdin);
            new_card.meaning[strcspn(new_card.meaning, "\n")] = '\0';
            
            printf("Example :");
            fgets(new_card.example, sizeof(new_card.example), stdin);
            
            printf("Category :");
            fgets(new_card.category, sizeof(new_card.category), stdin);
            new_card.category[strcspn(new_card.category, "\n")] = '\0';

            new_card.correct_count = 0;
            new_card.wrong_count = 0;

            cards[*count] = new_card;
            (*count)++;
            printf("Added「%s」!\n\n", new_card.word);

        }
/*登録されている単語カードを一覧表示する関数*/
void list_words(WordCard card[], int count){
    if (count == 0){
        
        printf("Unregistrated word\n\n");
        return;
    }
    printf("=== Registrated word (%d) ===\n", count);
    
for (int i = 0; i < count; i++) {
    
    printf("%d. %s - %s [%s]\n", i + 1, card[i].word, card[i].meaning, card[i].category);
    }
    
    printf("\n");
}

int main(void) {

	WordCard card[MAX_WORDS]; /*単語カードを入れておく配列*/
    int word_count = 0; /*何枚登録されているか*/

    int choice;

while (1) {
    printf("=== Words ===\n");
    printf("1 : Add a word\n");
    printf("2 : Look up the list\n");
    printf("3 : End\n");
    printf("3 : Choose\n");

    scanf("%d", &choice);
    getchar();

    if (choice == 1){
        add_word(card, word_count);
    } else if (choice == 2) {
        list_words(cards, &word_count);
    } else if (choice == 3){
        printf("End\n");
        break;
    } else {
        printf("Put a number 1~3\n");
    }
}
	return 0;

}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: