Thread: Segmentation fault

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I don't know which ones are good, but here are some C++ wrappers:
    SQLite CVSTrac

    You forget things when you deal with low-level stuff like C, and it also leads to more bugs, which is exactly why you are recommended to use a C++ wrapper, and not the C library directly.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by C_programmer.C
    Well! the talk of what strcmp returns would come far after I get some success in properly executing sqlite3_prepare_v2 then sqlite3_step and then strcmp. And then would be the time I should google for the return values of strcmp or some other basic functions.
    In that case, remove the strcmp code and whatever else you don't need to demonstrate the problem. If they are wrong, you are going to get comments about them. Hence, they just distract from your problem. Either get them right or remove them until you are ready to add them in.

    Quote Originally Posted by C_programmer.C
    you might know that there is no concept of strcmp and its return values in C#......
    There appears to be a CompareTo method that uses the same concept in C#.

    Anyway, you have yet to do what Salem stated: check the actual error code (also, the extended error codes).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    Here I go for what you all have advised to me. I found a wxSQLite3 Library which is a C++ + wx wrapper of SQLite.
    Code:
    #include "DataBase.h"
    #include <string>
    #include <wx/wxsqlite3.h>
    #include <wx/msgdlg.h>
    
    bool CanClose(void)
    {
        wxSQLite3Database DB;
        wxSQLite3ResultSet RS;
        DB.Open(_("SysConfig"),_(""),WXSQLITE_OPEN_READWRITE);
        if(DB.IsOpen())
        {
            RS=DB.ExecuteQuery("SELECT config_value from configuration WHERE config_id = 1;");
            if(RS.IsOk())
            {
                wxString WS;
                WS=RS.GetAsString(_("config_value"));
                //wxMessageBox(WS);
                if(WS.IsSameAs(_("YES")))
                {
                    DB.Close();
                  //  wxMessageBox(_("Returning True"));
                    return true;
                }
                else
                {
                    DB.Close();
                    return false;
                }
            }
        }
        else
        {
            wxMessageBox(_("Can not Open System Files"),_("Error!"));
            DB.Close();
            return false;
        }
        DB.Close();
        return false;
    }
    But still that myth is unsolved that why sqlite3_prepare_v2 was not working
    Last edited by C_programmer.C; 12-04-2012 at 09:36 AM.

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, what does the doc say about how to find out what error occurred when a function fails?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation Fault?
    By ronaldh12 in forum C Programming
    Replies: 4
    Last Post: 02-11-2012, 03:28 PM
  2. Segmentation fault.
    By Dizzy++ in forum C Programming
    Replies: 12
    Last Post: 12-12-2010, 10:57 PM
  3. Segmentation fault
    By bijan311 in forum C++ Programming
    Replies: 3
    Last Post: 12-12-2010, 11:45 AM
  4. segmentation fault
    By bazzano in forum C Programming
    Replies: 2
    Last Post: 09-29-2005, 02:13 AM
  5. segmentation fault and memory fault
    By Unregistered in forum C Programming
    Replies: 12
    Last Post: 04-02-2002, 11:09 PM