My code is with the following error and I am not seeing and not understanding what it is.
80: 6: Error: static declaration of 'print_menu' follows non-static declaration void print_menu () {
14: 6: note: previous declaration of 'print_menu' was here void print_menu ();
Code:
/* <-- BIBLIOTECAS --> */
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include "game_pvp.h"
/* <-- BIBLIOTECAS --> */
/* <-- DEFINES --> */
#define TAM 3
/* <-- DEFINES --> */
/* <-- DECLARAÇÃO DE PROCEDIMENTOS --> */
void print_menu();
void print_new_game();
void print_game_level();
void print_pvp_menu();
/* <-- DECLARAÇÃO DE PROCEDIMENTOS --> */
/* <-- MAIN --> */
int main(){
char menu_choice;
char game_shape[TAM][TAM];
int start_player;
srand(time(NULL));
print_menu();
menu_choice = getch();
while(menu_choice < 49 || menu_choice > 51) {
printf("\n Please enter a valid option");
menu_choice = getch();
}
if(menu_choice == 49){
system("cls");
print_new_game();
menu_choice = getch();
while(menu_choice < 49 || menu_choice > 50) {
printf("\n Please enter a valid option");
menu_choice = getch();
}
if(menu_choice == 49){
system("cls");
print_game_level();
menu_choice = getch();
while(menu_choice < 49 || menu_choice > 51) {
printf("\n Please enter a valid option ");
menu_choice = getch();
}
system("cls");
// CHAMA JOGADOR vs IA Passando o nivel
}
else{
system("cls");
print_pvp_menu();
start_player = (rand() % 2) + 1;
if(start_player == 1){
printf("\n O Player 1 comeca (press any key)");
}
else{
printf("\n O Player 2 comeca (press any key)");
}
getch();
system("cls");
// CHAMA JOGADOR vs JOGADOR Passando a vez
game_pvp(game_shape, start_player);
}
}
// Aqui entra game save e EXIT
system("pause");
}
/* <-- MAIN --> */
/* <-- PROCEDIMENTOS --> */
void print_menu(){
printf("\n -=- JOGO DA VELHA -=- \n");
printf("\n 1 - New Game");
printf("\n 2 - Saved game");
printf("\n 3 - EXIT");
printf("\n Enter your choice ");
}
void print_new_game(){
printf("\n -=- JOGO DA VELHA -=- \n");
printf("\n 1 - One player");
printf("\n 2 - Two players");
printf("\n Enter your choice ");
}
void print_game_level(){
printf("\n -=- GAME LEVEL -=- \n");
printf("\n 1 - Easy");
printf("\n 2 - Medium");
printf("\n 3 - Hard");
printf("\n Enter your choice ");
}
void print_pvp_menu(){
printf("\n -=- PLAYER vs PLAYER -=- \n");
printf("\n X - Player 1");
printf("\n O - Player 2");
printf("\n\n Sorteando quem vai comecar ...");
}
/* <-- PROCEDIMENTOS --> */
compiling_error:
C:\Users\Gabriel\Desktop\jogo da velha\main.c:80:6: error: static declaration of 'print_menu' follows non-static declaration
void print_menu(){
^~~~~~~~~~
C:\Users\Gabriel\Desktop\jogo da velha\main.c:14:6: note: previous declaration of 'print_menu' was here
void print_menu();
^~~~~~~~~~
C:\Users\Gabriel\Desktop\jogo da velha\main.c:88:6: error: static declaration of 'print_new_game' follows non-static declaration
void print_new_game(){
^~~~~~~~~~~~~~
C:\Users\Gabriel\Desktop\jogo da velha\main.c:15:6: note: previous declaration of 'print_new_game' was here
void print_new_game();
^~~~~~~~~~~~~~
C:\Users\Gabriel\Desktop\jogo da velha\main.c:95:6: error: static declaration of 'print_game_level' follows non-static declaration
void print_game_level(){
^~~~~~~~~~~~~~~~
C:\Users\Gabriel\Desktop\jogo da velha\main.c:16:6: note: previous declaration of 'print_game_level' was here
void print_game_level();
^~~~~~~~~~~~~~~~
C:\Users\Gabriel\Desktop\jogo da velha\main.c:103:6: error: static declaration of 'print_pvp_menu' follows non-static declaration
void print_pvp_menu(){
^~~~~~~~~~~~~~
C:\Users\Gabriel\Desktop\jogo da velha\main.c:17:6: note: previous declaration of 'print_pvp_menu' was here
void print_pvp_menu();
^~~~~~~~~~~~~~
C:\Users\Gabriel\Desktop\jogo da velha\main.c:108:1: error: expected declaration or statement at end of input
}
^
game_pvp.h:
#include "game_pvp.c"
game_pvp.c:
int game_pvp(char game_shape[3][3], int turn){
char x, y;
if(turn == 1){
print_shape(turn);
printf("\n Enter a value for X: ");
x = getch();
printf("%c",x);
while(x < 49 || x > 51 ){
printf("\n Please enter a valid option");
x = getch();
}
printf("\n Enter a value for Y: ");
y = getch();
printf("%c",y);
while(y < 49 || y > 51 ){
printf("\n Please enter a valid option");
y = getch();
}
}
else{
print_shape(turn);
printf("\n Enter a value for X: ");
x = getch();
printf("%c",x);
while(x < 49 || x > 51 ){
printf("\n Please enter a valid option");
x = getch();
}
printf("\n Enter a value for Y: ");
y = getch();
printf("%c",y);
while(y < 49 || y > 51 ){
printf("\n Please enter a valid option");
y = getch();
}
}
void print_shape(int turn){
printf("\n -=- PLAYER %i TURN -=- \n", turn);
printf("\n");
printf(" 1 2 3 Y\n");
printf("\n");
printf(" 1 X | X | X \n");
printf(" ---|---|--- \n ");
printf("2 X | X | X \n");
printf(" ---|---|--- \n ");
printf("3 X | X | X \n");
printf("\n X\n");
}