Help me with the J loop itz suppose to terminate on hitting enter to pass on loop to the outer loop for incrementing row.
I tried a[j]!=(char)13 but it failed.

#include<iostream.h>
#include<conio.h>
void main()
 {
 clrscr();
 int no=0,i=0,j,k,m,price[20];
char arr[20][50];
cout<<"    ================================================================="<<endl;
cout<<"                     Food on the run Restaurant              "<<endl;
cout<<"                          Hungry Kay ??                      "<<endl<<endl;
cout<<"    ================================================================="<<endl;
cout<<"Manager's screen"<<endl<<endl;
cout<<"Enter how many items to be there in the menu"<<endl;
cin>>no;
cout<<"Enter today's menu"<<endl;
for(i=0; i<no; i++)
{
[B][U] for(j=0; j<??;j++) // condition to end J is the error[/U][/B]
 {
 cin>>arr[i][j];

 }
 cout<<"Enter the price of the item"<<endl;
 cin>>price[i];
}
for(k=0; k<no; k++)
 {
 cout<<endl;
  for(m=0; arr[k][m]!='\0'; m++)
  {
  cout<<arr[k][m];
  }
  cout<<"                               "<<price[k];
 }
getch();
}

Why even use a J loop? If you want to enter strings then just do this:

for(i=0; i<no; i++)
    cin>>arr[i];

You won't get spaces in the above, so if you need the spaces too then use getline()

for(i=0; i<no; i++)
    cin.getline(arr[i], sizeof(arr[i]));

no its a menu list.....

Burger
Patty
Pizza

Anf its specified in the assing ment to input and store in a 2D array.

But those menu lists are strings. "Burger" is a string and "Patty" is another string. Treat them as you would any other string.

>>Anf its specified in the assing ment to input and store in a 2D array.
The suggestions I posted meet that requirement.

how is that a two D array itz just arr a 1D array....Plz just gimme the corr. condition for the loop.

char arr[20][50]; You declared it as a 2d array. cin will do the difficult part of filling in the 2nd dimension for you like you were attempting to do.

>>how is that a two D array itz just arr a 1D array
arr is still a 2d array. If you aren't still convinced then try out the code I posted and see for yourself how it works.

then how will the rows increase ?? asking coz I might get viva on the proj.

I already posted examples of how to do it. The i loop increments the rows. The j loop you coded increments the columns. But you don't need the j loop because cin will do that for you.

This question has already been answered. Start a new discussion instead.