string lost

hey i am working on a project that creates html for the user, note that i barely know any html. the problem is a good about of code does not ever get input into the html file.
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
#include <iostream>
#include <fstream>
#include <string> 
#include <exception> 
#include <ctype.h> 

class htmlfile{
private:
    std::string filename;
    std::ofstream savefile; 
    bool ishead; 
public:
    
    bool runprogram(){
        std::string returnR; 
        ishead = false;
        char eord; 
        savefile.exceptions(std::ofstream::failbit | std::ofstream::badbit);
        std::cout << "Enter a title for your webpage: ";
        getline(std::cin, filename); 
        std::string hold; 
        hold = filename;
        filename = "/Users/home/Desktop/dreamweaver/dreamweaver/"; 
        filename += hold; 
        filename += ".html"; 
        try{
            savefile.open(filename.c_str());
        }
        catch (std::ofstream::failure &e){
            std::cout << "An error has occured";
            return false; 
        }
        savefile << "<html><head><title>" << hold << "</title>"; 
        std::cout << '\n' << "What color would you the backgroud (G)rey, (C)arolina blue, Wolfpack (R)ed, or Duke (B)lue: ";
        std::cin >> eord; 
        savefile << backcolor(eord); 
        while ( eord != 'Q'){
        std::cout << "Add an element to your web page. Select an action: (T)ext, (H)orizonal Rule, (Q)uit: ";
        std::cin >> eord;
            eord = toupper(eord); 
            switch (eord){
            case 'T':
                    returnR = paragraph();
                    savefile << returnR;
                    break; 
            case 'H':
                    returnR = horozonal();
                    savefile << returnR; 
                    break; 
            case 'Q':
                    returnR = ender(); 
                    savefile << returnR;
                    savefile.close(); 
                    return true; 
                default:
                    std::cout << "entered in wrong text";
                    break; 
            }
        }
        return true; 
    }
     
    std::string horozonal(){
        std::string returnR = "<hr />";
        return returnR; 
    }
    
    std::string ender(){
        std::string returnR = "</body></html>";
        return returnR; 
    }
    
    std::string paragraph(){
        std::string returnR, a;
        char c;
        std::cout << "is this text a (H)eading, or a (P)aragraph text? ";
        std::cin >> c;
        switch (c) {
           case 'H':
                if(ishead == false){
                std::cout << "What styles would you like to apply to this text? (select all that apply) (B)old, (C)enter, change (F)ont, (N)one: ";
                std::cin >> a; 
                returnR += fontstyle(a); 
                    return returnR;
                    ishead =true; 
                }
                break; 
            case 'h':
                if(ishead == false){
                    std::cout << "What styles would you like to apply to this text? (select all that apply) (B)old, (C)enter, change (F)ont, (N)one: ";
                    std::cin >> a; 
                    returnR += fontstyle(a); 
                    ishead = true; 
                    return returnR;
                }
                break;
           case 'P':
                std::cout << ""; 
                returnR += fontstyle(a); 
                returnR += paradd(); 
                return returnR;
            case 'p':
                std::cout << ""; 
                returnR += fontstyle(a); 
                returnR += paradd(); 
                return returnR;
                
        }
        return returnR; 
    }
    
    std::string paradd(){
        char c; 
        std::string returnR; 
        std::cout << "what would you like to do: add a (L)ink, add a line (B)reak, add more (T)ext, (E)nd the paragraph: "; 
        std::cin >> c; 
        c = toupper(c); 
        if(c == 'L') returnR += link();
        if(c == 'B') returnR += "<br />";
        if(c == 'T') returnR += text(); 
        if(c == 'E') returnR += "</p>"; 
        return returnR; 
    }
    
    std::string link(){
        std::string returnR = "<a href=\"", a; 
        std::cout << "enter the url: ";
        std::getline(std::cin, a); 
        returnR += a;
        returnR += "\">";
        std::cout << "Enter the link text to be displayed: ";
        std::getline(std::cin, a);
        returnR += a;
        returnR += "<\a>";
        return returnR; 
    }
     
    std::string fontstyle(std::string s){
        std::string returnR = "<body><h1 style=\"font-weight:";
        for(int i = 0; i < s.length(); i++){
            s[i] = tolower(s[i]); 
            if(s[i] == 'b') returnR+=" bold;";
            if(s[i] == 'C') returnR+=" text-align: center;";
            if(s[i] == 'f') returnR+= setfont(); 
        }
        text(); 
        returnR += "</h1>"; 
            return returnR; 
    }
    
    std::string setfont(){
        int font; 
        std::string returnR = "font-family: "; 
        std::cout << "what font size: ";
        std::cin >> font; 
        returnR += font;
        returnR += ";";
        return returnR; 
    }
    
    std::string text(){
        std::string returnR = "font-family: ", words; 
        char c; 
        std::cout << "Which font would you like to choose? (A)rial, (T)imes New Roman, (I)mpact, (C)omic Sans MS : ";
        std::cin >> c; 
        c = toupper(c); 
        switch (c){
                case 'A':
                returnR += "arial;"; 
                break;  
                case 'T':
                returnR += "times new roman;";
                break; 
                case 'I':
                returnR += "impact;";
                break;
                case 'C':
                returnR += "comic sans ms;"; 
                break;
        }
        std::cin.ignore(); 
        std::cout << "Enter your text: ";
        std::getline(std::cin, words);  
        returnR += "\">"; 
        returnR += words; 
        return returnR; 
    }
    
    std::string backcolor(char c){
        c = toupper(c); 
        while ( c != '\n'){
        switch(c){
            case 'G':
                return "<style type = \"text/css\">body {background-color: #99999; color: #999999;</style></head>"; 
            case 'C':
               return "<style type = \"text/css\">body {background-color: #99CCFF; color: #99CCFF;</style></head>"; 
            case 'R':
                return "<style type = \"text/css\">body {background-color: #FF0000; color: #FF0000;</style></head>"; 
            case 'B':
                return "<style type = \"text/css\">body {background-color: #0000CC; color: #0000CC;</style></head>"; 
            default:
                std::cout << "you entered an invalid color\n please enter a color: ";
                std::cin >> c; 
                c = toupper(c); 
                break; 
        }
        }
        return NULL; 
    }
};

int main(){
    htmlfile active_file;
    active_file.runprogram(); 
    return 0;
}

the input/output exchange for a user is something like
Enter a title for your webpage: hello world

What color would you the backgroud (G)rey, (C)arolina blue, Wolfpack (R)ed, or Duke (B)lue: r
Add an element to your web page. Select an action: (T)ext, (H)orizonal Rule, (Q)uit: t
is this text a (H)eading, or a (P)aragraph text? h
What styles would you like to apply to this text? (select all that apply) (B)old, (C)enter, change (F)ont, (N)one: bc
Which font would you like to choose? (A)rial, (T)imes New Roman, (I)mpact, (C)omic Sans MS : a
Enter your text: hello world
Add an element to your web page. Select an action: (T)ext, (H)orizonal Rule, (Q)uit: h
Add an element to your web page. Select an action: (T)ext, (H)orizonal Rule, (Q)uit: t
is this text a (H)eading, or a (P)aragraph text? p
Which font would you like to choose? (A)rial, (T)imes New Roman, (I)mpact, (C)omic Sans MS : c
Enter your text: hello world
what would you like to do: add a (L)ink, add a line (B)reak, add more (T)ext, (E)nd the paragraph: e
Add an element to your web page. Select an action: (T)ext, (H)orizonal Rule, (Q)uit: q

the info stored within the file is
<html><head><title>hello world</title><style type = "text/css">body {background-color: #FF0000; color: #FF0000;</style></head><body><h1 style="font-weight: bold;</h1><hr /><body><h1 style="font-weight:</h1></p></body></html>


alot of the code is lost and i am not sure why that is. i think i messed up my return sequence but if someone could point out that error it would be great.
Topic archived. No new replies allowed.