我想通過使用Visual Studio 2012來做一個猜測C語言遊戲的字母,但是我不斷收到錯誤和警告,我不知道如何解決它們。我不斷收到的錯誤是:在C程序中猜字遊戲,困惑錯誤
1)警告1警告C4133: '功能':不兼容的類型 - 從 'FILE *' 到 '爲const char *'
2)警告2警告C4047: '=':'FILE *'與'int(__cdecl *)(FILE *)'的間接級別不同'
3)錯誤3錯誤C2449:在文件範圍發現'{'(缺少函數頭?
4.)錯誤4錯誤C1004:意外結束文件中找到
5.)智能感知:argum類型的 「FILE *」 ENT是與參數不相容
6.)智能感知:類型爲 「int(__cdecl *)(FILE * _File)」 不能被分配給類型的實體 「FILE *」
的值我也看到錯誤,說'預計一個聲明。'每當我嘗試解決問題時,我最終都會在其他方面引發更多問題。有人可以幫我嗎?謝謝!
這裏是我的代碼:
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#define MAXGUESSES 5
int SingleGame(char file_letter);
int main()
{
//declare additional variables
int PlayGames = 4,
i = 0;
FILE * infile;
char letter;
//display instructions
printf("Welcome to the Letter Guessing Game!\n");
printf("You will enter the number of games that you want to play, which is 1-4 games\n");
printf("You have 5 chances to guess each letter\n");
printf("Let's begin!\n");
//open file
infile = fopen("lettersin.txt", "r");
//get number of games to play
printf("How many games would you like to play?(1-4)\n");
scanf("%d", &PlayGames);
for(i=0;i<PlayGames;i++)
{
//get a letter from file
scanf(infile, " %c", &letter);
//Play one game
printf("Let's play a game %d\n", i);
//check for win or lose
SingleGame (letter);
}
//close file
infile = fclose;
return 0;
}
int SingleGame(char file_letter);
{
//Function definitions
int numGuesses = 0;
while(numGuesses < MAXGUESSES);
char RetrieveGuess = 0;
int PlayGames = 0;
{
printf("Enter a guess\n");
scanf("%c" , &RetrieveGuess);
if(file_letter == RetrieveGuess);
{
printf("You guessed it!\n");
}
else
{
if(file_letter>RetrieveGuess)
{
printf("The letter you are trying to guess comes before:%d\n",RetrieveGuess)
}
{
else if(file_letter<RetrieveGuess)
{
printf("The letter you are trying to guess comes after:%d\n", RetrieveGuess)
}
{
numGuesses = numGuesses +1;
}
「SingleGame」函數的其餘部分在哪裏? – PaulMcKenzie 2015-02-12 02:23:18