V
vinhkan
just learning c++. trying out this small routine to demonstrate how to
center text on the screen. It's a function called "int cent(int)"
doesn't work for me. could you take a look for me.
thanks
Mark
/* This is my main menu program */
#include <iostream.h>
//FUNCTION PROTOTYPES
int cent(int );
void burger();
void fries();
void frappe();
void hotdog();
void icecream();
void coke();
void pepsi();
//BEGIN MAIN
int main()
{
//int cent(int );
int name = 0 ;
cout
<<"1=burger\n"<<"2=fries\n"<<"3=frappe\n"<<"4=hotdog\n"<<"5=icecream\n"<<"6=coke\n"<<"7=pepsi\n"<<
endl;
cin >> ws;
cin >> name;
if (name==1)
{
cent(32);cout<<burger();
}
else
if(name==2){
fries();}
else
if(name==3)
frappe();
else
if(name==4)
hotdog();
else
if(name==5)
icecream();
else
if(name==6)
coke();
else
if(name==7)
pepsi();
else
cout<<"Not on the menu!\n";
return 0;
}
void burger()
{
cout<<"Thank you for ordering a burger\n";
}
void fries()
{
cout<<"Thank you for ordering fries\n"<<endl;
}
void frappe()
{
cout<<"Thank you for ordering a
frappe\n";
}
void hotdog()
{
cout<<"Thank you for ordering a
hotdog\n";
}
void icecream()
{
cout<<"Thank you for ordering an
icecream\n";
}
void coke()
{
cout<<"Thank you for ordering a
coke\n";
}
void pepsi()
{
cout<<"Thank you for ordering a
pepsi\n";
}
int cent(int len)
{
int j;
j = 39 - (len/2);
for(int i = 1; i < (j+1); i++)
cout << "";
return 0;
}
center text on the screen. It's a function called "int cent(int)"
doesn't work for me. could you take a look for me.
thanks
Mark
/* This is my main menu program */
#include <iostream.h>
//FUNCTION PROTOTYPES
int cent(int );
void burger();
void fries();
void frappe();
void hotdog();
void icecream();
void coke();
void pepsi();
//BEGIN MAIN
int main()
{
//int cent(int );
int name = 0 ;
cout
<<"1=burger\n"<<"2=fries\n"<<"3=frappe\n"<<"4=hotdog\n"<<"5=icecream\n"<<"6=coke\n"<<"7=pepsi\n"<<
endl;
cin >> ws;
cin >> name;
if (name==1)
{
cent(32);cout<<burger();
}
else
if(name==2){
fries();}
else
if(name==3)
frappe();
else
if(name==4)
hotdog();
else
if(name==5)
icecream();
else
if(name==6)
coke();
else
if(name==7)
pepsi();
else
cout<<"Not on the menu!\n";
return 0;
}
void burger()
{
cout<<"Thank you for ordering a burger\n";
}
void fries()
{
cout<<"Thank you for ordering fries\n"<<endl;
}
void frappe()
{
cout<<"Thank you for ordering a
frappe\n";
}
void hotdog()
{
cout<<"Thank you for ordering a
hotdog\n";
}
void icecream()
{
cout<<"Thank you for ordering an
icecream\n";
}
void coke()
{
cout<<"Thank you for ordering a
coke\n";
}
void pepsi()
{
cout<<"Thank you for ordering a
pepsi\n";
}
int cent(int len)
{
int j;
j = 39 - (len/2);
for(int i = 1; i < (j+1); i++)
cout << "";
return 0;
}