hi, i'm new in this site.. i'm working on a airplane seat reservation program..
we were asked to design a program that chooses the users' desired row number and the desired seat number (or rather in this case, seat letter)... here's my code

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
struct flight_reservation
{ int a[21];
};
char c, s;
clrscr();
printf("Enter your choice");
printf(" a. View all seats\n");
printf(" b. Reserve a seat\n");
printf(" c. Exit");
scanf("%c",&c);
switch(c)
{case 'a': {clrscr();
  printf("1.\tA\tB\tC\tD\n");
  printf("2.\tA\tB\tC\tD\n");
  printf("3.\tA\tB\tC\tD\n");
  printf("4.\tA\tB\tC\tD\n");
  printf("5.\tA\tB\tC\tD\n");
  getch();} break;
 case 'b': {int w, y;
 char s[21]={'A','B','C','D','A','B','C','D','A','B','C','D','A','B','C','D','A','B','C','D'};
 printf("Choose row");
 scanf("%d",&w);
 switch(w)

   case 1: printf("Choose a column"); scanf("%c",&s);
	   {int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)break;
   case 2: printf("Choose a column"); scanf("%c",&s);
	   int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)  break;
   case 3: printf("Choose a column"); scanf("%c",&s);
		int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)  break;
   case 4: printf("Choose a column"); scanf("%c",&s);
	  int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)  break;
   case 5: printf("Choose a column"); scanf("%c",&s);
	  int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)  break;
	   }
 case 'c': clrscr();
      printf("Thanks! Come Again!");
      getch();
      exit(0);
      default: printf("Invalid Input!");
      getch();
}

well, my problem is, it doesn't work after the user inputs his/her desired row number.. the program just exits... and i'm not even sure if it will work out well.... please, i just need some help... thanks...

case 1: printf("Choose a column"); scanf("%c",&s);
	   {int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)break;
   case 2: printf("Choose a column"); scanf("%c",&s);
	   int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)  break;
   case 3: printf("Choose a column"); scanf("%c",&s);
		int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)  break;
   case 4: printf("Choose a column"); scanf("%c",&s);
	  int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)  break;
   case 5: printf("Choose a column"); scanf("%c",&s);
	  int v;
	     for(v=0;v<20;v++)
	       if(s[v]='A'||s[v]='B'||s[v]='C'||s[v]='D')
		 s[v]='*'}
		 printf("%s",s)  break;
	   }

You're using the assignment operator (=) rather than the equality operator (==) in your "if" statements. Also you have

void main ()

instead of

int main ()

Here's a link to why you shouldn't do that:

http://www.daniweb.com/forums/thread10221.html

thanks for your reply.. it worked.. but my program is wrong, it didn't turned out the way it should.. but i already did a new one, and it works fine... it only has a little problem.. but i think i can take it from here... thanks for your help again...

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.