**DISREGARD**
1 2 3 4 5 6 7 8 9
|
#include <iostream>
int main()
{
std::string spacer;
spacer=" ";
std::cout<<spacer<<"1"<<spacer<<"2"<<spacer<<"3";
}
|
What I think you are trying to do is space out the numbers by
9 whitespaces. First of all, there is no use for
#include <string> because you are not using functions defined from
string header. Next, if you want a
string with
9 spaces, you do not do
(9,' '), you either define
std::string spacer to be
" " or create a for loop like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char spacer[77];
for(int i=0;i<9;i++)
{
strcat(spacer," ");
}
std::cout<<spacer<<"1"<<spacer<<"2"<<spacer<<"3";
}
|
In this case, we are using the
strcat function, so we have to include <
string.h>.
Finally, you are not using the variable
s,
spacer, or
ruler. When you define a variable and don't use it, it is like throwing it away and letting it rot.
EDIT:
whitenite is using
<iomanip>, which you must define if you want to use the functions. Also, he agrees that you are throwing away variables.
**DISREGARD**