code showing segmentation fault
<p>the following code shows segmentation fault.where is the mistake all i figure out is its in the line containing printf() statement but not sure why is it and how to correct it.Can anyone help me out here..</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;stdio.h&gt;
#include&lt;string&gt;
#include&lt;readline/history.h&gt;
#include&lt;readline/readline.h&gt;

using namespace std;
int main()
{
    using_history();
    string command("history");
    add_history(command.c_str());
if (command == "history")
{
    cout&lt;&lt; "hello\n";
    for(int i = 0 ; i &lt; history_length ; i++)
    {
        cout&lt;&lt;"in there\n";
        HIST_ENTRY *entry = history_get(i);
        cout&lt;&lt;"till here\n";
        printf("%5d %s", i , entry-&gt;line);
    }
}
return 0;
}
</code></pre>
