Multiline String

As you can see, when I add my CSS I have quotes around every line for the CSS. Is it possible to have a multi line string so I could do:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
string g = "a whole bunch of text
                  a lot more text";
 

[code]#include <iostream> //cin, cout
#include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <string> //getline(), string


using namespace std;
void HTML_Start(string);
void HTML_End(string);

void HTML_Start(string Class, string Date, string File_Name, string Name, string Title){
    string szCSS = "<style>"
                "html {"
				"background-color: white;"
				"padding: 10px;"
				"font-family: sans-serif;"
				"font-size: 15px;"
			"}"
			"body {"
				"background-color: #f6f6f6;"
				"box-shadow: 0 2px 8px rgba(0,0,0,.5);"
				"display: table;"
				"padding: 0;"
				"margin: 0;"
				"position: relative;"
				"z-index: 0;"
				"width: 100%;"
			"}"
			"address {"
				"position: fixed;"
				"top: 5%;"
				"right: 1%;"
				"text-align: right;"
				"font-size: smaller;"
				"font-style: normal;"
			"}"
			"h1 {"
				"position: absolute;"
				"left: 120px;"
				"top: 40px;"
				"font-size: larger;"
				"font-weight: normal;"
				"text-decoration: underline;"
			"}"
			"ol {"

				"border-left: 2px solid rgba(255,0,30,.25);"
				"border-right: 2px solid rgba(255,0,30,.05);"
				"padding: 0;"
				"margin: 0;"
				"margin-left: 100px;"
				"margin-right: 80px;"
				"position: relative;"
				"z-index: 0;"
				"float: left;"
				"width: 80%;"
			"}"
			"ol li {"
				"padding: 0;"
				"margin-left: -104px;"
				"margin-right: -81px;"
				"padding-left: 110px;"
				"padding-right: 100%;"
				"border-bottom: 2px solid rgba(0,160,255,.1);"
				"line-height: 30px;"
				"height: 30px;"
				"width:100%;"
			"}"
			"ol li:first-child {"
				"border-top: 2px solid rgba(0,160,255,.1);"
				"margin-top: 120px;"
			"}"
			"ol li:last-child {"
				"margin-bottom: 50px;"
			"}"
			"ol::after {"
				"position: absolute;"
				"bottom: 50px;"
				"right: -65px;"
				"color: rgba(0,160,255,.16);"
				"line-height: 30px;"
				"font-weight: 400;"
				"font-family: \'Mrs Sheppards\', cursive;"
				"letter-spacing: 2px;"
			"}"
			"ol::before {"
				"content: \"\";"
				"background-color: white;"
				"box-shadow: 0 2px 4px rgba(0,0,0,.5) inset;"
				"height: 25px;"
				"width: 25px;"
				"border-radius: 25px;"
				"position: absolute;"
				"top: 105px;"
				"left: -75px;"
			"}"
			"body::before {"
				"content: "";"
				"background-color: white;"
				"box-shadow: 0 2px 4px rgba(0,0,0,.5) inset;"
				"height: 25px;"
				"width: 25px;"
				"border-radius: 25px;"
				"position: absolute;"
				"top: 50%;"
				"left: 27px;"
			"}"
			"body::after {"
				"content: "";"
				"background-color: white;"
				"box-shadow: 0 2px 4px rgba(0,0,0,.5) inset;"
				"height: 25px;"
				"width: 25px;"
				"border-radius: 25px;"
				"position: absolute;"
				"bottom: 105px;"
				"left: 27px;"
			"}"

			".container{"
				"width:auto;"
				"max-width: 100%;"
				"height:100%;"
				"overflow: hidden;"
			"}"

			"em {"
				"font-weight: bold;"
				"font-style: oblique;"
			"}"
			"</style>";

    string szTitle = "<title>" + Title + "</title>";
	ofstream Definition_HTML;
    Definition_HTML.open(File_Name, ios::app); //add to end of file
    Definition_HTML << "<!DOCTYPE html> <html> <head> <meta charset=\"UTF-8\">"
                    << szTitle
                    << szCSS
                    << "</head> <body>"
                    << "<div class=\"container\">"
                    << "<address>" + Name + "<br>" + Class + "<br>" + Date + "</address>"
                    << "<h1>" + Title + "</h1>"
                    << "<ol>";
    Definition_HTML.close();

}

void HTML_End(string File_Name){
    ofstream Definition_HTML;
    Definition_HTML.open(File_Name, ios::app);
    Definition_HTML << "</ol></div></body></html>";
    Definition_HTML.close();

}

int main()
{
    //Declare Variables
    string szClass = "";
    string szDate = "";
    string szDefinition = "";
    string szExtension = "Def.html";
    string szFile_Name = "Definitions.html";
    string szList_Item = "";
    string szName = "";
    string szTitle = "";
    string szWord = " ";

//Start main function of program
    cout << "This is a program that automatically formats your definitions. \n It then proceeds to create a web page for easy viewing."
            "Hopefully, at some point, it will automatically get the definition for you and create a quiz."
            "\n\n";

    cout << "Name: ";
    getline(cin, szName); //Gets Name of User
    cout << "\n" << "Class and Period: ";
    getline(cin, szClass); //Gets Class
    cout << "\n"
         << "Press ENTER for today's date."
         << "\n"
         << "Date: ";
        getline(cin, szDate); //Gets date user inserts
        if (szDate == "")
        {
            szDate = "this_is_today's_date_place_holder"; //If user hits enter, then display current date
        }
        else { szDate = szDate; //Not sure if 'else' is required, but if so, it sets Date to itself
        }

        cout <<  "\n" << "Page Title: ";
        getline(cin, szTitle); // Gets the title and H4 of the page

    HTML_Start(szClass, szDate, szFile_Name, szName, szTitle);
    szFile_Name = szTitle + szExtension; //set the name of file to the title and Def.html

    while(szWord != ""){
            cout <<"Word: ";
            getline(cin, szWord); //Get intended word
            cout << "\n Definition: ";
            getline(cin, szDefinition); //get intended defintion
            szList_Item = "<li><em>" + szWord + "-</em> " + szDefinition + "</li>";//Concates and makes HTML li tag
            ofstream Definition_HTML; //Ofstream Declaration
            Definition_HTML.open(szFile_Name, ios::app); //Add to end of file; Sets the name of file to szFile_Name
            Definition_HTML << szList_Item; //inserts szList_Item
            Definition_HTML.close(); //close
        }
    HTML_End(szFile_Name);

}

Last edited on
Try using #include<stringstream>
Topic archived. No new replies allowed.