Advice on a String Program?

I've never coded before, and I'm taking my first intro to C++ class.

I'm just going to admit that this is a homework question. I'm not asking for the solution, because I've already tried to create my own, but I would like some advice. I need to create this rocket: http://i46.tinypic.com/mucd0.png.

My program just says it's "1 Up-to-Date" instead of "1 Success" when I try to compile, and the console isn't displaying anything at all.

I'm too new to even proofread my own work or understand what this code should look like, so I may be totally off. I don't even know what errors to look for. Could someone please help me identify what might be causing the issue, or at least point me in the right direction?

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
#include <iostream>
#include <string>
using namespace std;

int main()  
{
	// To build a rocket!
	
	// Assign values to the rocket perimeter objects.
	string rocketLeft('/');
	string rocketRight('\');
	string space1(' ');
	string space2(2, ' ');
	string space6(6, ' ');
	string rocketStraight('|');
	string screw('+');
	string bar(6, '-');
	

	// To form the top and bottom of the rocket.
	string tip = rocketLeft + rocketRight + '\n' +
		     rocketLeft + space1 + rocketRight + '\n' +
		     rocketLeft + space2 + rocketRight;
	
	// To form the horizontal part of the rocket.
	string seam = screw + bar + screw;
	
	// To form the straight walls of the rocket.
	string wall = rocketStraight + space6 + rocketStraight + '\n' +
		      rocketStraight + space6 + rocketStraight;

	// To form the middle of the rocket.
	string middle = seam + '\n' + wall + '\n' + seam + '\n' +
			wall + '\n' + seam + '\n' + wall;


	// To display the rocket.
	string display = tip + '\n' +
                         middle + '\n' +
		         seam + '\n' +
			 tip; 
	
	cout << display << endl;
	return 0;
} 


Thank you for any advice.
Last edited on
1 up to date means your compiler is not going to compile anything since you already compiled it. Are you actually running the program or just compiling it?
For running it are you pressing the debug tab up top and then start without debugging? Thats how you run a program
Thanks, guys. I was just building it and not running it. It did say it succeeded when I tried it again.

Now that I've tried to start it without debugging, the console comes up but doesn't say anything except to "Press any key..." I assume it should be coming up with the rocket instead.
Line 11 - you need to escape the backslash so it is '\\' and not '\', it thinks you are escaping the quote. How could you not notice that all your code is the color of text?
I don't know why it compiles in your case actually, I would assume it gave you some errors to work with, as it did with me :P

first of all:
string rocketRight('\');

the backslash \ isn't really read just like that. The compiler expects a symbol to come right after the backslash, and together they will be seen as 1 char of some sort. Just like the newline you use several times (\n)
to get around this problem, just type 2 backslashes:
string rocketRight("\\");
the first backslash tells the compiler there is a special symbol coming, and the second one is the special symbol

secondly:
instead of:
string space1(' ');
you should use:
string space1(1,' ');
or
string space1(" ");
(this is an error that you have on several lines)

I don't really know the difference between " and ' myself, so if anyone else wants to explain that, I'd be very happy :D
The reason why this gives you an error is because your arguments don't match with the expected arguments :)
Thank you, L B and simpleasy. That worked! I appreciate it. I have a few more tweaks, but now it's at least showing up in the console.
Topic archived. No new replies allowed.