Hi Ricardo,
On 15 August 2018 at 06:26, Ricardo Lima <[email protected]> wrote:
> I built a straightforward program in C. It's just a STACK structure (first
> in, last out) that takes input from the user and stores it into the stack.
> After I close the program, all the data vanishes since I don't have a
> database implemented into the program. Even so, the program runs fine. It
> allocates memory according to the user's input, and I always validate every
> allocation.
>
> In fact, my issue isn't concerning C code itself. It's the implementation of
> SQLite into the C code. Every stack_node has a value (integer), date (char),
> and info (char). The wallet structure is the "middle-man" between the
> stack_node and the DB, and it has the same attributes plus an ID (integer
> autoincremented). What I'm trying to do is to as soon as the user inputs data
> (while the program is running) this data gets stored not only in the stack
> but also in the DB. After the user is done inputting data, I usually use
> pop_stack() to retrieve the data from the stack onto the screen, but since
> the data is stored in the DB, it makes more sense just to extract all data
> from the DB.
>
> I don't get any compilation errors and the SQLite source files/header files
> are implemented correctly into the code. I know this because I'm using SQLite
> Studio ( SQLite GUI) and I see all the attributes from the wallet DB, but
> they are all empty.
> So, that's my issue. I'm doing something wrong that causes the program to not
> store the data correctly into the DB.
in
if( push_stack( s, value, date, info ) ){
addData( db, node );
}
node is always NULL, and addData checks for that, and does nothing...
> --- Is it a waste of memory and running time for the program to create a
> stack, stack_node etc...to only after all that store the information in the
> DB? Should I just skip all that and program just for the DB? If so, how would
> I do that since I would eventually run into the same problem. I'm using the
> stack because I might have more control over what I can do with the data like
> adding the values, calculate average expenditure and so on.
>
> Thank you so much!
Regards,
Simon
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users