为什么我会收到错误错误:'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
最满意答案
下面应该做的诀窍,其中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))
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
如何限制一个数字的范围(How to limit a number to a range)[2022-11-25]
%(模数)适用于浮点值,因此使用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?)[2022-08-25]
试试这个: =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 than ... -
不太清楚你在这里后的情况,但这里有: 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: lastNum ...
-
下面应该做的诀窍,其中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 pr ...
-
将数字限制在一个范围内(Limiting a number to a range)[2022-09-24]
如果你想要喜欢它,这很好地工作: 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 nicely: ... -
移动数字范围的中点(Shift Middle Point of Number Range)[2022-10-28]
我不明白为什么你需要这样的映射,但是这样做的方法是: 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 - valmin ) ... -
选择范围内的范围(selecting a range within a range)[2023-08-04]
可以确认这种行为: 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.Rang ... -
检查数字是否在范围内(Check if number is in range)[2023-10-30]
扩展@ Daniel的答案,还有另外两个错误:第一, $('#enterTime').value()不是有效的jQuery函数,应该是$('#enterTime').val() 。 其次,您需要将值转换为Number 。 否则,您将尝试访问不存在的字符串的between属性。 最终的代码是: function timeCheck(){ var time = new Number($.trim($('#enterTime').val())); Number.prototype.between ...