首页 \ 问答 \ 为什么我会收到错误错误:'char'之前的预期表达式?(Why do i get the error error: expected expression before ‘char’?)

为什么我会收到错误错误:'char'之前的预期表达式?(Why do i get the error error: expected expression before ‘char’?)

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

这是我的函数,它打印一个10乘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’

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

This is my function that prints an array of 10 by 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");
    }
}

The function that uses the above function. I get one error here.

void findThecookie(){
    drawMap(char map[10][10], int i, int j);
}

This is my main function.

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();
    }

Another error here

if(gamenumber == 4){
    findThecookie(char map[10][10], int i, int j);
}
if(gamenumber == 5){
    printf("Exiting the program\n");
} 

return 0;

Everytime i try to compile i get the errors

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’

原文:https://stackoverflow.com/questions/19438150
更新时间:2024-04-23 16:04

最满意答案

下面应该做的诀窍,其中A1是你正在寻找的值,B1是范围的下限,C1是范围的上限。 您可能在<或>之前/之后不需要'=',它仍然具有相同的结果。

=IF(A1<=B1,B1,IF(A1>=C1,C1,A1))

The below should do the trick, where A1 is the value you're looking for, B1 is the lower bound of the range, C1 is the upper bound of the range. You probably don't need the '=' before/after the < or >, it still has the same result.

=IF(A1<=B1,B1,IF(A1>=C1,C1,A1))

相关问答

更多

相关文章

更多

最新问答

更多
  • CSS修复容器和溢出元素(CSS Fix container and overflow elements)
  • SQL多个连接在与where子句相同的表上(SQL Multiple Joins on same table with where clause)
  • nginx 80端口反向代理多个域名,怎样隐藏端口的
  • xcode提醒样式,swift 3(xcode alert style, swift 3)
  • 在Chrome控制台中调试JavaScript(debugging javascript in Chrome console)
  • Javascript - 试图围绕自定义事件(Javascript - Trying to wrap my head around custom events)
  • 边栏链接不可点击(Sidebar links aren't clickable)
  • 使用recpatcha gem时如何显示其他表单错误?(How do I display other form errors when using the recpatcha gem?)
  • boost.python避免两次注册内部类,但仍然在python中公开(boost.python Avoid registering inner class twice but still expose in python)
  • Android 现在软件很少吗?以后会多起来吗
  • 如何在ActiveAdmin 0.5.0中为资源全局指定预先加载?(How to specify eager loading globally for a resource in ActiveAdmin 0.5.0?)
  • matlab代码为黄金比例持续分数(matlab code for golden ratio continued fraction)
  • Android浏览器触摸事件位置(Android browser touch event location)
  • 将cURL输出分配给Bash中的变量(Assign output to variable in Bash)
  • 我如何在MVC视图上没有时间获取当前日期(how i can get current date without time on MVC view)
  • sql连接函数(sql join of function)
  • 为什么在Xamarin Media插件中使用ImageSource.FromStream而不是FromFile?(Why use ImageSource.FromStream instead of FromFile in Xamarin Media plugin?)
  • 这段代码是否真的可以防止SQL注入?(Will this code actually work against SQL-injection? [duplicate])
  • 信阳方远计算机学校大专证被国家认可么
  • React / Rails AJAX POST请求返回404(React/Rails AJAX POST request returns 404)
  • Android与php服务器交互(Android interact with php server)
  • 自动刷新QTableWidget可能吗?(Refresh QTableWidget automatically possible?)
  • JVM / Compiler优化对象的未使用属性(optimization of unused properties of object by JVM / Compiler)
  • 插入表格时,乌克兰字符会更改为问号(Ukrainian character change to question mark when insert to table)
  • 在头文件中包含异常类(Including an exception class in a header file)
  • 完成c#中的执行后关闭sqlcmd(Close sqlcmd after finishing executing in c#)
  • 使用软导航栏正确检测屏幕尺寸(Detecting screensize correctly with soft navigation bar)
  • Typescript:从输入更新值(Typescript : update value from input)
  • 如何在执行某些行后仅在断点处停止?(How to only stop at a breakpoint after some line was executed?)
  • 以未定义的元素在JSON中循环(loop in JSON with undefined elements)