1. Learn how to indent code.
Code:
#include<stdio.h>
void DisplayFunc(int r, int w, int SeatF[7][10])
{
int i, j;
printf("\n-----------------------------SCREEN------------------------------\n\n\n");
for (i = 0; i < r; i++) {
printf("%c", 65 + i);
for (j = 0; j < w; j++) {
if (SeatF[i][j] == 0) {
printf(" |0%d|", j);
} else
printf(" |**|");
}
printf("\n");
}
}
int seatselling()
{
int i, j, count = 0, seat;
char s1[3], s2[3], SeatF[7][10], flag[10][10], n;
printf("input your seat range 1:");
scanf("%s", &s1);
printf("input your seat range 2:");
scanf("%s", &s2);
for (i = s1[1]; i <= s2[1]; i++)
SeatF[s1[0] - 65][i - 49] == 1;
DisplayFunc(7, 10, SeatF);
}
int main()
{
int i, j, SeatF[7][10];
for (i = 0; i < 7; i++) {
for (j = 0; j < 10; j++) {
SeatF[i][j] = 0;
}
}
DisplayFunc(7, 10, SeatF);
seatselling();
system("PAUSE");
}
2. Get a decent compiler and turn up the warning level.
Code:
$ gcc -Wall -Wextra foo.c
foo.c: In function ‘seatselling’:
foo.c:24:9: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[3]’ [-Wformat=]
scanf("%s", &s1);
^
foo.c:26:9: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[3]’ [-Wformat=]
scanf("%s", &s2);
^
foo.c:29:5: warning: statement with no effect [-Wunused-value]
SeatF[s1[0] - 65][i - 49] == 1;
^
foo.c:31:22: warning: passing argument 3 of ‘DisplayFunc’ from incompatible pointer type [-Wincompatible-pointer-types]
DisplayFunc(7, 10, SeatF);
^
foo.c:2:6: note: expected ‘int (*)[10]’ but argument is of type ‘char (*)[10]’
void DisplayFunc(int r, int w, int SeatF[7][10])
^
foo.c:21:50: warning: unused variable ‘n’ [-Wunused-variable]
char s1[3], s2[3], SeatF[7][10], flag[10][10], n;
^
foo.c:21:36: warning: unused variable ‘flag’ [-Wunused-variable]
char s1[3], s2[3], SeatF[7][10], flag[10][10], n;
^
foo.c:20:24: warning: unused variable ‘seat’ [-Wunused-variable]
int i, j, count = 0, seat;
^
foo.c:20:13: warning: unused variable ‘count’ [-Wunused-variable]
int i, j, count = 0, seat;
^
foo.c:20:10: warning: unused variable ‘j’ [-Wunused-variable]
int i, j, count = 0, seat;
^
foo.c: In function ‘main’:
foo.c:44:3: warning: implicit declaration of function ‘system’ [-Wimplicit-function-declaration]
system("PAUSE");
^
foo.c: In function ‘seatselling’:
foo.c:32:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
In particular, you need to pay attention to the type of SeatF you have all over the place, and "warning: statement with no effect".