怎么读.dat的数据文件?怎么判断是文本模式还是二进制文件?如果用fscanf逐个读入,以字符型、以整形或者以浮点型数据读入结果有差别吗

如何读.dat的数据文件?如何判断是文本模式还是二进制文件?如果用fscanf逐个读入,以字符型、以整形或者以浮点型数据读入结果有差别吗?
fscanf(file_pointer, "%lf", &var); 

fscanf(file_pointer, "%d", &var); 

fscanf(file_pointer, "%c", &var);

------解决方案--------------------
这个,是你想获取什么类型的数据才用什么样的吧,再说一般文件中的格式你要清楚,才能得到你需要的吧
------解决方案--------------------
windows的文本模式和二进制模式有严重的区别,因为windows以某个特殊字节作为文件结束符,所以如果是二进制文件就千万别用文本模式去fgets,fscanf等等。

而linux和windows截然不同,linux以read系统调用返回0作为文件结束符,所以在linux下默认都是二进制打开,是完全不在乎这个参数的。


The mode string can also include the letter 'b' either as a last character or as a character between the characters in any of the two-character
strings described above. This is strictly for compatibility with C89 and has no effect; the 'b' is ignored on all POSIX conforming systems,
including Linux. (Other systems may treat text files and binary files differently, and adding the 'b' may be a good idea if you do I/O to a
binary file and expect that your program may be ported to non-UNIX environments.)
------解决方案--------------------
读字符,空格会读的。。