ファイルの内容を読み取るだけのこの小さなプログラムを作成していますが、実行すると次のエラーが発生します。
また、Xcode からも警告が表示されます。コード (main.c) の 10 行目で、「割り当てにより、キャストなしで整数からポインターが作成されます」:
#include <stdio.h>
#include <stdlib.h>
#define FILE_LOCATION "../../Data"
int main (int argc, const char * argv[]) {
FILE *dataFile;
char c;
if ( dataFile = fopen(FILE_LOCATION, "r") == NULL ) {
printf("FAILURE!");
exit(1);
}
while ( (c = fgetc(dataFile)) != EOF ) {
printf("%c", c);
}
fclose(dataFile);
return 0;
}
これはデバッガーの出力です。
[Session started at 2012-06-27 10:28:13 +0200.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
Loading program into debugger…
Program loaded.
run
[Switching to process 34331]
Running…
Program received signal: “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all
(gdb)
ポインター、間違った関数に問題がありますか? NSZombie と呼ばれるメモリの問題を追跡するものを見つけました。これは何ですか?使用できますか?