0

How can I underline a text ??

cout<<"Hungry Kya ??"

output needs to be
Hungry Kya ??

Also is there a predefined function to get the numbers of rows of a 2D array ??

0

>>Yes I am using Tc++ v3.0 I suppose
suppose isn't good enough.

You could use getche() but it is even more clumsy because it requires a loop.

0

How can I underline a text ??

cout<<"Hungry Kya ??"

output needs to be
Hungry Kya ??

Also is there a predefined function to get the numbers of rows of a 2D array ??

not possible with MS-Windows and your compier. Years ago with MS-DOS 6.X it could be done, but that's not supported any more. To do it today you have to use win32 api console functions, but you can't do that with your compiler.

0

to arrage the inputted raw 2D array I first need to count the number of rows how can i do it ?

0

>>void Menu (char list[5][20], float price[5])

Do you mean the number of rows in the above function? If yes, the answer is 5. If not then I don't know what you are talking about.

0

But what if the user inputs 3 ?? then ?? asking the user how many items he will input look way too primitive.

0
void Menu (char list[30][30], float price[30]);
{
// 30 rows max. 30 coloums max.
cout<<"                     Food on the run Restraunt              "<<endl;
cout<<"                          Hugry Kay ??                      "<<endl;
//Arranging the menu.
for(i=0;list[i]!='\0';i++)<<--------------------- problem
{
cout<<" list[i][30]<<----- how to terminate at null char in the coloum ??

what will be the condition?

0

If you initialize that array with 0s when it is declared then just check if the first character is 0.

for(i=0; list[i][0] != '\0'; i++)<<--------------------- problem
{
0

I still don't get it....... how do I arrange the placement of endl;

I want to run the loop if a row exists till the colom reads a null char.
as the colom will read a null char it should place endl;
and increment row by 1.

0

kk I have done some changes I have made the row variable to be entered in the program as to make things a bit easy for me.

0
void Menu (char list[30][30], float price[30],int a)
{
// 30 rows max. 30 coloums max.
// a is the number of items.
#include<conio.h>
int n=0,i=0;
cout<<"                     Food on the run Restraunt              "<<endl;
cout<<"                          Hugry Kay ??                      "<<endl;
//Arranging the menu.
for(i=0;list[n][i]!='\0';i++)
{
cout<<list[n][i]<<"                     "<<price[n]<<endl;
n++;
if(n==a)
   {
    cout<<"----------------xxxxxxxx-----------------------------"<<endl;
    exit();
   }
}
return(0);
}

how can I include the header file for endl, cout and exit ??

error- Linkage specification not allowed.

0

Do you mean you want to print the menu text to start somewhere other than at the left side of the screen ? The you need to use setw() function found in <iomanip>

#include <iomanip>
#include <string>
#include <iostream>
// other includes here
using namespace std;

int main()
{
    // Center the text with screen width of 80 columns
    std::string text = "some menu item";
    int center = (80 - text.length())/2;

    .. now diaplsy it
    cout << setw( center - (text.length()/2)) << text << "\n";
}

produces this output

some menu item
Press any key to continue . . .
0

no!!!! plz read my last message.....
I am trying to cout the 2D array which will consist of the food names and the the price...
dots are spaces.
2D arr.............................................price

Burger............................................30

I am almost done I have posted the code just having the header file error.
It demands header for end(), cout, endl;
and when I put the headers it gives error.
LINKAGE SPECIFICATION NOT ALLOWED.

0

PLz solve this prog. then both my functions will be over.
Itz 12:35 AM in In India..... and I also have to study for chemistry.

0

>>It demands header for end(), cout, endl;
See the header files in my post. All those are in <iostream>.

As for the text placement, you still use setw() function.

int nSpaces = 23;
int i = 0; // a loop counter
cout << setw(0) << list[i] << setw(nSpaces) << "price\n";

you will probably have to adjust variable nSpaces on each line to accommodate different string lengths.

0

PLz solve this prog. then both my functions will be over.
Itz 12:35 AM in In India..... and I also have to study for chemistry.

Sorry, but my task is to just help you solve YOUR problem. What time it is in India is not my problem. I think with the help I've given you in my previous post you should be able to solve the program yourself. The trick is the setw() function to adjust the spacing.

0

#include <iomanip>
#include <string>
#include <iostream>
// other includes here
using namespace std;

int main()

why int main() ??
I wanna input the header in the fuction.

0

you mean like this???

int main()
{
   #include <string>

That's not the way its done. put the headers at the top of the file so that they are global to everything in the file.

>>why int main() ??
every c++ program has a main function, its required by the ISO standards. If you don't know that then you are just wasting your and my time with this thread. Go to bed and get some sleep, then things will be clearer tomarrow.

0

I mean why not void main() after all it dosen't return any int value it returns void value.

0

I still get the linkage error, I will complete the rest of my program with my teacher tomoro. in school anywayz thanx fr the help.

0

>>I mean why not void main() after all it dosen't return any int value it returns void value.

main() always returns a value whether you specify one or not. int main() and int main(int argc, char* argv[]) are the only two valid ways to declare it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.