Weird bug...advice please.

It is kind of hard to explain exactly what is going on. So I will paste my code, as well as a screen shot to better illustrate the problem.


http://pastebin.com/m13339027 <-- Code

http://www.imagedump.com/index.cgi?pick=get&tp=546328 < -- Screen Shot


So basically I am making a small HTML editor that works flawlessly so far, provided you only pick a 1 word title, and a 1 word header. However if you pick a 2 word title it skips one of the follow steps, if you pick a 3 word title it skips 3 of the following steps. This is illustrated in the screenshot.

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
   1.
      #include <iostream>
   2.
      #include <fstream>
   3.
       
   4.
      using namespace std;
   5.
       
   6.
      int main()
   7.
      {
   8.
       
   9.
      string title;
  10.
      string bgcolor;
  11.
      string txtcolor;
  12.
      string header;
  13.
       
  14.
      cout << "Enter a title for ur site: ";
  15.
      cin >> title;
  16.
       
  17.
      cout << "\n";
  18.
       
  19.
      cout << "Pick a color for your background: ";
  20.
      cin >> bgcolor;
  21.
       
  22.
      cout << "\n";
  23.
       
  24.
      cout << "Pick a text color for all the text: ";
  25.
      cin >> txtcolor;
  26.
       
  27.
      cout << "\n";
  28.
       
  29.
      cout << "What would you like your header to be: ";
  30.
      cin >> header;
  31.
       
  32.
       
  33.
       ofstream myfile;
  34.
       myfile.open ("test.html");
  35.
       myfile << "<body bgcolor=" << bgcolor << ">";
  36.
       myfile << "<title>" << title << "</title>";
  37.
       myfile << "<body text color=" << txtcolor << ">";
  38.
       myfile << "<center><h1>" << header << "</center></h1>";
  39.
       myfile.close();
  40.
       
  41.
       return 0;
  42.
       
  43.
       
  44.
      }



you should replace cin >> title; (line 15) with getline( cin, title );
You should include <string>
http://www.cplusplus.com/forum/articles/6046/
alright I did used getline( cin, title ); for the title and it seemed to work perfect...then I went ahead and did that getline( cin, header); for the header so they can have more than 1 line header and it seems to skip the part where you input the header....

after you input the text color it skips the input for the header and ends the program....

http://pastebin.com/m30c7ac56
Actually nevermind, I got it all working. I just did

getline( cin, txtcolor );
getline( cin, title );
getline( cin, bgcolor);
getline( cin, header);

for all of the inputs, now it all works just perfect :)
Topic archived. No new replies allowed.