Bättre förklaring än att testa det finns nog inte så här är koden:
Kod: Markera allt
#include <iostream>
#include <fstream>
#include <string>
#include <sys/stat.h>
#include <sys/types.h>
using namespace std;
int main()
{
//xhtml-koden till index
string xhtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"sv-SE\" lang=\"sv-SE\">\n\t<head profile=\"http://www.w3.org/2000/08/w3c-synd/#\">\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n\t\t<title>Ny sida</title>\n\t\t<link href=\"style/style.css\" rel=\"stylesheet\" type=\"text/css\" />\n\t</head>\n\n\t<body>\n\t</body>\n</html>";
//css-koden
string css = "body {\n\tmargin: 0px;\n\tfont-family: Helvetica, Verdana, Arial, sans-serif;\n\tfont-size: 12px;\n\tcolor: #000000;\n}";
//Skapar mappar. Förklaring: gfx=grafik, style=css, lib=oophp, inc=filer för inkludering, dbconn=databasanslutning, script=javascript.
const char *mappar [] = {"gfx", "style", "lib", "inc", "dbconn", "script"};
int mkdir(const char *pathname, mode_t mode);
for(int i=0; i< (sizeof(mappar)/sizeof(*mappar)); ++i)
{
mkdir(mappar[i], S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH | S_IROTH);
}
//Skapar och skriver till index
ofstream index;
index.open ("index.html");
index << xhtml << endl;
index.close();
//Skapar och skriver till css
ofstream style;
style.open ("style/style.css");
style << css << endl;
style.close();
return 0;
}
//Gl&HF!