我发现了类似的问题,但我认为它们不适用于我的具体问题,所以如果有,我很抱歉!
我作为一年级 CS 学生正在学习 C,并试图用 C 进行测验,但我无处可去,因为每次我尝试编译以查看它是否工作时,我都会收到消息“警告:初始化使指针来自没有强制转换的整数。”
我已经解决了所有的语法错误(我认为),但我只是一辈子都想不通。我已经浏览了我所有的演讲幻灯片,但没有一个涵盖这一点。
#include <stdio.h>
#include <scc110.h>
int player1score, player2score;
char* answer1, answer11, answer111, answer2, answer22, answer222;
int geography()
{
printf ("The first category is geography. Note: Player 1 always goes first.\n");
char* answer1 = AskForStringAndWait("Player 1: What is the capital of India?");
if (strcmp(answer1,"New Delhi")==0)
player1score++;
char* answer2 = AskForStringAndWait("Player 2: What is the capital of Iran?");
if (strcmp(answer2,"Tehran")==0)
player2score++;
char* answer11 = AskForStringAndWait("Player 1: Name a country that borders France that isn't Germany, Italy or Spain.");
if (strcmp(answer11,"Luzembourgh")==0 ||
strcmp(answer11,"Switzerland")==0 ||
strcmp(answer11,"Belgium")==0)
player1score++;
char* answer22 = AskForStringAndWait("Player 2: Name one of the main British Channel Islands.");
if (strcmp(answer22,"Guernsey")==0 ||
strcmp(answer22,"Jersey")==0)
player2score++;
}