Last active
November 12, 2015 18:04
-
-
Save bzdgn/122c6b5dc79327dc26c8 to your computer and use it in GitHub Desktop.
BoilerPlate Database Sample On C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* cl: cl /nologo /W4 bpdb.c */ | |
/* gcc: gcc bpdb.c -Wall -Wextra -pedantic -std=c11 -o bpdb */ | |
#include <stdio.h> | |
#define OPEN 1 | |
#define CLOSED 0 | |
typedef struct | |
{ | |
int SomeState; | |
char *filename; | |
char *statement; | |
} | |
Connection; | |
void OpenConnection(Connection *db, char *filename) | |
{ | |
db->SomeState = OPEN; | |
db->filename = filename; | |
} | |
void ExecuteConnection(Connection *db, char *statement) | |
{ | |
db->statement = statement; | |
} | |
void CloseConnection(Connection *db) | |
{ | |
db->SomeState = CLOSED; | |
} | |
int main() | |
{ | |
Connection db; | |
OpenConnection(&db, "C:\\temp\\sample.db"); | |
ExecuteConnection(&db, "create table People (Id int, Name text)"); | |
CloseConnection(&db); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment