Hello everyone. I have a database with fields not required to be filled in
(the other fields are declared NOT NULL). When I have a record with the
non-required fields empty, and copied it to my structure, there is a memory
fault (core dumped) error. Here is the snippet of my code:

            if (pdata) {
                for (index = 0; index < p_out.r_count; index++) {
                    // p_ptr will contain the record (row) from the table 
                    p_ptr = p_out.ppp_data[index];
                    
                    // accessing the elements of the pointer to the record
(row)
                    pdata->info_id = atoi((p_ptr[0]));
                    strncpy(pdata->surname, (p_ptr[1]), 100);
                    strncpy(pdata->firstname, (p_ptr[2]), 100);
//#if 0
                    memcpy(pdata->nickname, (p_ptr[3]), 100); <- probable
error source (not required fields)
                    pdata->age = atoi((p_ptr[4]));                   <-
probable error source (not required fields)
//#endif
                    strncpy(pdata->position, (p_ptr[5]), 100);
                    strncpy(pdata->teamname, (p_ptr[6]), 100);
                    strncpy(pdata->teamclient, (p_ptr[7]), 100);
                    
                    // increment pointer to move to next record
                    pdata++;
                }
                
                // output the contents of pdata
                *all_records = pdata;
            }
            else {
                result = MEM_ERROR;
            }

Thanks for the help in advance.
-- 
View this message in context: 
http://www.nabble.com/SQLite-DB-memory-fault-error-tp19308790p19308790.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to