Jump to content

Can C structures be written to the hard drive?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
DarkLordoftheMonkeys

DarkLordoftheMonkeys

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
I'm trying to figure out how to create a simple RDBMS in C. I think the tables in the database could be implemented as arrays of structures. For instance, the statement:


struct users {

	char username[50];

	char password[15];

	char gender[1];

	int age;

} *table;


would be executed when the user of the database inputs:


CREATE TABLE users (

username VARCHAR(50),

password VARCHAR(15),

gender VARCHAR(1),

age INTEGER

);


The problem is that arrays and structures only last for the duration of execution, so I would need some way of writing the data to the hard drive. Is this possible? Sorry if this is a dumb question.
Life's too short to be cool. Be a nerd.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
My thinking, off hand, is that you would do string parsing and a linked list of void *'s to build the tables structure.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog