0
Hello, I would like help to try to solve the problem of an matrix of my program in C. It was created the matrix saying that it should be filled with such a character, it even works, but the last line is always not displayed the character that was defined, and no matter how many rows and how many columns I place, the same thing always happens. I’ve read and reread the entire code, but I can’t find anything unusual. I thought it was overflow but for the little knowledge I have overflow does not occur in CHAR type variable. I’m sorry if I’m wrong
Follow the blocks of code:
STATEMENTS AND LIBRARIES:
#include <stdio.h>
#include<stdlib.h>
#include<conio.h>
#define COL 7
#define ROW 4
#define FALSE 0
#define TRUE 1
void inicializa(char matriz[ROW][COL]);
void mostrarPainel(char matriz[ROW][COL]);
void comprar(char matriz[ROW][COL]);
void reservar(char matriz[ROW][COL]);
void legenda();
int menuOpcao();
int colunaY();
int linhaX();
MENU SWITCH:
inicializa(matriz); //Iniciliza a matriz com valores .(Livre)
do{
system("cls");//Limpa a tela
opcao=menuOpcao();
switch(opcao){
case 1:
system("cls");
system("cls");
mostrarPainel(matriz);//Mostra o Painel atualizado
comprar(matriz); // Realiza a compra de uma cadeira no painel, marcando c/ um X
break;
case 2:
system("cls");
system("cls");
mostrarPainel(matriz);
reservar(matriz); //Realiza a reserva de uma cadeira no painel, marcando c/ um R
break;
case 3:
system("cls");
mostrarPainel(matriz);
getch();
break;
case 4:
loopContinue = FALSE; //condicao para saída do programa
}
}while(loopContinue);
getchar();
return 0;
}
-----------------------------------------------------------------------------
void inicializa(char matriz[ROW][COL]){
int i,j;
for(i=1;i<=ROW;i++)
for(j=1;j<=COL;j++)
matriz[i][j] = '.';
}
void mostrarPainel(char matriz[ROW][COL]){
int i,j;
printf("\n\n %c PAINEL DE OCUPACOES %c\n\n",16,17);
printf(" ");
for(i=1;i<=COL;i++)
printf("%d ",i);
for(i=1;i<=ROW;i++){
printf("\n\n %d",i);
for(j=1;j<=COL;j++)
printf(" (%c)",matriz[i][j]);
}
//apresenta o menu na tela
legenda();
}
------------------------------------------------------------------