#include <stdio.h>
#include <stdlib.h>
#include <time.h>
这是我的函数,它打印一个 10 x 10 '.' 的数组。
void drawMap(char map[10][10]){
int i, j;
printf("Now drawing map\n");
for(i = 0; i < 10; i++){
for(j = 0; j < 10; j++){
map[i][j] = '.';
printf("%c ", map[i][j]);
}
printf("\n");
}
}
使用上述函数的函数。我在这里遇到一个错误。
void findThecookie(){
drawMap(char map[10][10], int i, int j);
}
这是我的主要功能。
int main()
{
int gamenumber;
int randomNumber;
int guessednum;
printf("Hello and welcome to my babysitting game.\n");
printf("Please select your option. Your choices are:\n");
printf("1) Number guessing game\n" "2) Rock-Paper-Scissors\n" "3) Area of a Random Rectangle\n" "4) Find the Cookie\n" "5) Quit\n");
scanf("%d", &gamenumber);
if(gamenumber == 1){
numberGuessing();
}
if(gamenumber == 2){
rockPaperscissors();
}
if(gamenumber == 3){
randomRectangle();
}
这里的另一个错误
if(gamenumber == 4){
findThecookie(char map[10][10], int i, int j);
}
if(gamenumber == 5){
printf("Exiting the program\n");
}
return 0;
每次我尝试编译时都会出现错误
project2.c: In function ‘findThecookie’:
project2.c:22:9: error: expected expression before ‘char’
project2.c: In function ‘main’:
project2.c:171:17: error: expected expression before ‘char’