/* This file is part of Olono Copyright (C) 2008 Martin Potier () and David Wagner () This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 3 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** \file * libDisplay.c (console) * Contient les fonctions d'affichage en mode console: * concerne aussi bien l'affichage de la grille que les entrées utilisateur. */ #include #include #include #include #include "libDefine.h" #include "libPlay.h" #include "libDisplay.h" //! Demande les coordonnées au joueur /** * Cette fonction demande à l'utilisateur les coordonnées du point à jouer * et les converti pour qu'elles correspondent aux indices en mémoire. */ void demanderXY(int coords[], int taillePlateau) { char x=0; int y=0; int retourScanf; do { printf("Entrez les coordonnées où jouer: "); scanf(" %c%d%*[^\n]", &x, &y); int c; // ... On vide le flux while ( ((c = getchar()) != '\n') && c != EOF); } while (!( x>=65 && (x-65)=0 && ycouleur]); } printf("\n"); // après chaque ligne, retour à la ligne } printf(" "); for (i=0;i 25)) { printf("Taille impaire (5-25) : "); retourScanf = scanf("%d%*[^\n]",&taillePlateau); // Si le scanf a retourné une erreur ... if (!retourScanf) { // ... On vide le flux int c; while ( ((c = getchar()) != '\n') && c != EOF); } else // Si tout s'est bien passé, on enlève le \n final getchar(); } return taillePlateau; }