2013-06-29 55 views
-6

我創建了一個函數來檢查打開的文件是否是位圖。我寫了以下功能:在檢查位圖圖像時遇到問題

 int auth(FILE *fp) 
     { 
      if (fgetc(fp)!='B' || fgetc(fp)!='M'){ 
        return 0; 
        } 
      else{ 
       return 1; 
        } 
      } 

但是這是給ERROR:"FILE and fp not declared in this scope"

有人可以幫助我嗎?

+4

你鍵入'FIle',不'FILE'。 – idoby

回答

1

必須包括<stdio.h>頭:

#include <stdio.h> 
2

正確的拼寫是FILE(以大寫所有字母)。

而且你必須#include <stdio.h>

+0

我已經包含了stdio.h並糾正了拼寫錯誤。 但它仍然給出相同的錯誤 –

+1

@tapansingh也許你沒有在任何地方糾正它。 – Elazar

0
  1. 包括`stdio.h
  2. 應該在首都FILE
0
int auth(FILE *fp) 
{ 
    if (fgetc(fp)!='B' || fgetc(fp)!='M') return 0; 
    else return 1; 
} 
+1

simpler:'return fgetc(fp)=='B'&& fgetc(fp)=='M';' – Elazar

+0

不錯,我會想到返回0或1,但是'&&'操作符會爲你做 – hit

+0

就像其他布爾運算符一樣。 – Elazar