Well heres the story...i have this problem im about to mention and i need alot of help with it....i read the Faq and i've done the best i could to get as much of the program done on my own and now i need somewhere to turn for help...nobody i know in person can help (even my professor is hard to get in touch with) and im praying somebody here will take the time to go through this with me. basically im writing a program as if i ran a restaurant and needed to assign people to thier seats (represented by a 2D array) I have 4 arrays (booth, table, smoking booth, smoking table) when the user goes in, they are asked if they want booth or table, then asked smoking or non. From there i have to go into an array (which is allready set up and filled with 'O's to mean its empty if i did that correctly) and change the O's to X's meaning someones there. When the next user request a table i have to make sure they are assigned to a whole new section of the array meaning i dont just pile them on the same table with others. Im trying to make it so the tables hold 4 people and the booths 6. I have ALOT of problems here...for one i dont have a C compiler at home and the school lab is down. If any of you can, please go through this and tell me what i should do to fix it or make it better. I know im missing alot and it needs to be cleaned up...im desperate and out of ideas. Thanks for any help....
Code:

printf("Hello and welcome to Empire Diner! Would you like a booth or table? Enter 1 for table, 2 for booth")
scanf("%d", &num1);
printf("Will that smoking or nonsmoking for tonight? Enter 1 for smoking, 2 for nonsmoking.");
scanf("%d", &num2);

//here is where i'd like to ask if its another customer (start over again without clearing array) or to just end the entire program. Ideas?

}

void table (void)
{
for (table = 0, table <= 24, table++)
{
if table[I][J] != 'X' //X will be used to indicate that seat is occupied
while seats < counter
{
if [J] > 4 //make sure you are not over the limit of seats for table
table[I][J] = 'X'; //still have available seat so fill it
counter++; //adds one to the counter

else

table[I][ ]++; //need new table to increment your table index (I)
table[][J] = 0; //initialize seat
table[I][J] = 'X';
counter++;
}
}
}
The rest of the functions will look like the above one, but i wont bother writing those if this one isnt even correct yet...once i see how one should look i'll make the rest. Thanks again if you straighton this mess out.... :confused:

All of this code is invalid. None of it is contained in a function. You cannot have global code like this. You can declare global variables, but you cannot have global code blocks, they must be contained in a function.

Additionally, you have not declared 'smokebooth', or any of the other arrays at this time.

Quote:

void main(void)
{

This is wrong. 'main' ALWAYS returns an 'int'. Thus, at the end of your 'main' block, you ad the following:

This would give you a simple menu. You should be able to get something working from here.

Quzah.

12-10-2001

novacain

Bit late but I think you should use int arrays for this.
I find int's easier to work with than characters and this is mainly a TRUE / FALSE question 'Is the seat full?', 'Is there room in non-smoking?'.

Watch your use of certain 'words'.
For example you use 'table' too much.
ie the function table() has a loop counter called table, an array called table.

Try TableAlloc() iTableIndex, and TableArray or that sort of thing. In the long run the extra typing will pay off. (after you have spent a few hours trying to find the place you used the wrong variable)

You have to give the arrays size.

So if you want 10 tables of 4 you will need to declare

char TableArray[10][4];

I would use a hash define and int array as easier to read in the long run.