Hey Just thought I might post some code I've
Been refining its not really useful but it shows (sort of) how to print formatted text if you have any suggestions please I've almost got the kinks out weird numbers will cause it to output weird. But if you throw 9 9 it will print out a nice little square. I did have the kinks worked out but my hard drive died so I lost a lot of good code.
Give me a sec I edit and post id rather not type 55 lines on my Ipod.
Eventually I will add the ability to just use arguements with out having to use the interactive mode.

#include <iostream>
#include <string>
using namespace std;

class DrawRect{
public:
void draw(int x,int y,string ch);
};

void DrawRect::draw(int x,int y,string ch){
int t,r,z;
string c;
t=x;r=y;c=ch;
for(z=0;z!=x; z++){
cout<<c;
}
cout<<endl;
for(int w=0;w!=y;w++){
//inside this loop we create a mini loop to loop "char        char"\n
cout<<c;
for(z=0;z!=x-2;z++){
cout<<" ";
}
cout<<c<<endl;
}
for(z=0;z!=x; z++){
cout<<c;
}
}

int main(int argc,char * argv[]){
int x,y;
string ca;
DrawRect r1;
/*if(argc>0){
x=atoi(argv[1]);
y=atoi(argv[2]);
ca=argv[3];
}*/
//else{
cout<<"DrawRect v2.04 rev a\n";
cout<<"Enter X:";
cin>>x;
cout<<"Enter Y:";
cin>>y;
cout<<"Enter a Character to use:";
cin>>ca;
r1.draw(x,y,ca);
cout<<endl;
//}
cin.get();
return 0;
}

can you post how should real output look like?

On linux using terminal. Runs on windows too for those of you new to programming :)
By the way where it say inside this loop blah blah blah. That is supposed to be a block comment not just a comment so that should cause compiler errors just wrap any thing that looks like a comment like this /* text blah blah more text*/

./rect
Enter x: 2
Enter y: 2
Enter a character: #

##
##

Thats what output should look like its more of a visual representation of a rectangle or " square "
Mainly it show how to output formatted text so that you dont have to type a ridiculous amount of cout statements and its sorta useful for repeatedly drawing shapes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.