#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ROWS 100
#define MAX_NAME 50
#define MAX_EMAIL 50
typedef struct {
int id;
char name[MAX_NAME];
char email[MAX_EMAIL];
} Row;
typedef struct {
int size;
Row rows[MAX_ROWS];
} Table;
void init_table(Table *table) {
table->size = 0;
}
void insert_row(Table *table, int id, const char *name, const char *email) {
if (table->size < MAX_ROWS) {
Row *row = &table->rows[table->size];
row->id = id;
strncpy(row->name, name, MAX_NAME);
strncpy(row->email, email, MAX_EMAIL);
table->size++;
} else {
printf("Error: Table is full\n");
【c语言】实现简单的数据库
于 2024-03-15 19:45:00 首次发布