PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : c++ Programm gibt fehler



Tuxist
18-02-2007, 11:06
Habe eine cgi anwendung geschrieben wenn ich diese bekomme ich die 'Fehlermeldung:



neo@neo:~/Desktop/tuxist.de/tuxcms$ ./index.cgi
Content-Type:text/html


<html>
<head>
<title></title>
</head>
<select name="Formselect1"<option>Forminput</option> <option>Forminput1</option> <option>Forminput2</option>method="GET">
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
Aborted



index.cpp


#include <iostream>
#include "index.h"
#include <dlfcn.h>
#include <tuxcms/css.h>
#include <tuxcms/libhtml++.h>
#include <string>

using namespace std;

int main()
{
string sitename;
cout << "Content-Type:text/html\n\n" << endl
<< "<html>" << endl
<< "<head>" << endl
<< "<title>" << sitename << "</title>" << endl
<< "</head>" << endl;


formselect("Formselect1", "Forminput Forminput1 Forminput2", "GET");
anfrage();
libcssread();
cout << "<body>" << endl
<< "<h1><em>" << endl
<< "Im Aufbau" << endl
<< "</em></h1>" << endl
<< "</body>" << endl
<< "</html>";
}

cgi.h


#include <iostream>
#include <string>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <vector>

using namespace std;

void anfrage()
{
string eingabe = getenv("QUERY_STRING");
cout << eingabe << endl;
}

locus vivendi
18-02-2007, 12:57
Die Meldung zeigt den Fehler eigentlich schon auf: Du initialisierst einen std::string mit einem Null-Zeiger. Das ist verboten. Du musst bedenken, dass getenv 0 zurückliefern kann.