garten

view clock.c @ 13:f1d43b52ed36

and here now is the main program
author meillo@marmaro.de
date Wed, 23 Jul 2008 15:20:35 +0200
parents 176ee28e7464
children 5e6c9260913a
line source
1 #include <stdio.h>
2 #include <stdlib.h>
4 #include "db.h"
5 #include "game.h"
10 void inc_time() {
11 /* get current time */
12 sprintf(query, "select time from game;");
13 db_query(query);
14 if (sqlite3_step(stmt) == SQLITE_ROW) {
15 gametime = sqlite3_column_int(stmt, 0);
16 } else {
17 fprintf(stderr, "error: %s\n", sqlite3_errmsg(db));
18 }
19 sqlite3_finalize(stmt);
21 /* increment time */
22 sprintf(query, " update game set time = '%d';", ++gametime);
23 if (!db_update(query)) {
24 printf("error: time update failed: %s\n", sqlite3_errmsg(db));
25 }
26 sqlite3_finalize(stmt);
27 }
30 void worldclock(void) {
31 inc_time();
32 printf("gametime: %d\n", gametime);
33 }