为什么我会收到错误错误:'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))

相关问答

更多

如何限制一个数字的范围(How to limit a number to a range)

%(模数)适用于浮点值,因此使用rotation % 360.0f (您需要将360.0以后添加到负数) % (modulus) works on floating point values so use rotation % 360.0f (you will need to add 360.0 afterwards to negative numbers)

如何使用公式计算excel [Range]中的数字出现次数?(How to count a number occurence in an excel [Range] using formula?)

试试这个: =SUM(LEN(Range) - LEN(SUBSTITUTE(Range, number, "")))然后在将公式输入单元格后按Ctrl + Shift + Enter而不是Enter键将其转换为数组公式。 Try this: =SUM(LEN(Range) - LEN(SUBSTITUTE(Range, number, ""))) and then turn it into an array formula by pressing Ctrl+Shift+Enter rather ...

如何从range()函数获取最后一个数字?(How do I get the last number from the range() function?)

不太清楚你在这里后的情况,但这里有: rangeList = range(0,21) lastNumber = rangeList[len(rangeList)-1:][0] 要么: lastNumber = rangeList[-1] Not quite sure what you are after here but here goes: rangeList = range(0,21) lastNumber = rangeList[len(rangeList)-1:][0] or: la...

如果超出范围的数字返回范围的极值,那么Excel中是否有任何函数给出数字和范围?(Is there any function in Excel that give a number and a range if the number out of a range return the extreme value of the range else the number ?)

下面应该做的诀窍,其中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. Y...

将数字限制在一个范围内(Limiting a number to a range)

如果你想要喜欢它,这很好地工作: r, g, b = (min(255, max(0, c)) for c in (r, g, b)) 例: In [1]: r, g, b = -1, 145, 289 In [2]: r, g, b = (min(255, max(0, c)) for c in (r, g, b)) In [3]: r, g, b Out[3]: (0, 145, 255) If you want to be fancy about it, this works nic...

移动数字范围的中点(Shift Middle Point of Number Range)

我不明白为什么你需要这样的映射,但是这样做的方法是: public static double Normalize( double val, double valmin, double valmax, double min, double max, double midpoint ) { double mid = ( valmin + valmax ) / 2.0; if ( val < mid ) { return ( val - valmin ) / ( mid - val...

选择范围内的范围(selecting a range within a range)

可以确认这种行为: Sub Tester() Dim rng As Range Set rng = Range("C3:H28") 'This selects E5:F6 (???) With rng .Range(.Cells(1, 1), .Cells(2, 2)).Select End With 'This selects C3:D4 (expected) With rng rng.Parent...

检查数字是否在范围内(Check if number is in range)

扩展@ Daniel的答案,还有另外两个错误:第一, $('#enterTime').value()不是有效的jQuery函数,应该是$('#enterTime').val() 。 其次,您需要将值转换为Number 。 否则,您将尝试访问不存在的字符串的between属性。 最终的代码是: function timeCheck(){ var time = new Number($.trim($('#enterTime').val())); Number.prototype.bet...

相关文章

更多

error C2668: 'M' : ambiguous call to overloaded function

以下是代码: #include&lt;iostream&gt;using namespace std ...

eclipse里报:An internal error occurred during:

eclipse里报:An internal error occurred during: Buildi ...

The connection to adb is down, and a severe error has occured.

启动android模拟器时.有时会报The connection to adb is down, an ...

solr error logs org.apache.solr.common.SolrException: ERROR: [doc=17] unknown field alias

在solr中 添加新的索引词语时,报如标题所示错误,指定是插入的字段没有在solr索引字段里 可以修改 ...

命令行运行Hbase: Session 0x0 for server null, unexpected error

又重新看了下hbase的操作,以前虽说是运行过对Hbase的操作,比如直接的建表,导入数据,或者是使用 ...

solr 4.4 Error filterStart 问题

纠结了很久的问题,https://wiki.apache.org/solr/SolrLogging#U ...

Solr安装异常:SolrException: Error loading class 'solr.VelocityResponseWriter'

解决方法安装Solr过程出现错误,报异常 org.apache.solr.common.SolrExc ...

[Hadoop] Error: JAVA_HOME is not set

在namenode启动脚本%Hadoop_HOME%/bin/start-dfs.sh的时候发现dat ...

Solr/Lucene escape char handling

+ - &amp;&amp; || ! ( ) { } [ ] ^ &quot; ~ * ? : \ ...

win8安装VirtualBox-4.2.18提示Installation failed!error:系统找不到指定的路径

在win8上安装VirtualBox-4.2.4-81684-Win.exe,提示Installati ...

最新问答

更多

python的访问器方法有哪些

使用方法: class A(object): def foo(self,x): #类实例方法 print "executing foo(%s,%s)"%(self,x) @classmethod def class_foo(cls,x): #类方法 print "executing class_foo(%s,%s)"%(cls,x) @staticmethod def static_foo(x): #静态方法 print "executing static_foo(%s)"%x调用方法: a =

使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)

我认为你必须将两个TableGetway传递给UserTable构造。 你必须改变Module.php看看: public function getServiceConfig() { return array( 'factories' => array( 'User\Model\UserTable' => function($sm) { $userTableGateway = $sm->get('UserTable

透明度错误IE11(Transparency bug IE11)

这是一个渲染错误,由使用透明度触发,使用bootstrap用于在聚焦控件周围放置蓝色光环的box-shadow属性。 可以通过添加以下类覆盖来解决它。 .form-control:hover { -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,255,1); -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,255,1); box-shadow: 0px 0px 4px 0px rgba(0,0,255,1)

linux的基本操作命令。。。

ls 显示目录 mkdir 建立目录 cd 进入目录

响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)

将z-index设置为.main-nav这将解决您的重叠问题 .main-nav { position:relative; z-index:9; } set z-index to .main-nav This will fix your overlaping issue .main-nav { position:relative; z-index:9; }

在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)

这是因为模式规范"a"打开一个文件以便追加,文件指针在末尾。 如果您尝试从此处读取,则由于文件指针位于EOF,因此没有数据。 您应该打开"r+"进行阅读和写作。 如果在写入之前读取整个文件,则在写入更多数据时,文件指针将正确定位以追加。 如果这还不够,请探索ftell()和fseek()函数。 That is because the mode spec "a" opens a file for appending, with the file pointer at the end. If you

NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)

支持空中接口的数据速率是一回事。 在消除协议开销,等待eeprom写入以及所有需要时间的其他内容之后,您看到的数据速率是完全不同的故事。 长话短说,从标签读取或进行对等传输时的实际数据速率峰值约为2.5千字节/秒。 取决于具体的标签或对等技术,它可能比这慢很多。 The supported data-rates of the air-interface are one thing. The data-rate that you see after removing protocol overhe

元素上的盒子阴影行为(box-shadow behaviour on elements)

它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂

Laravel检查是否存在记录(Laravel Checking If a Record Exists)

这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found

设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)

$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640