#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> int main() { char str[100] = "F:\视频\8.csv"; FILE *pf = fopen(str, "r"); if (pf == NULL) { return -1; } else { while (!feof(pf)) { char str[500] = { 0 }; fgets(str, 500, pf); fputs(str, stdout); } } getchar(); return 0; } 应该如何解决. |
|
20分 |
应该是格式的问题 .csv文件的格式,要不就用unicode去读,或者是有一个下划线什么open的一个函数也可以 哈哈
|
20分 |
FILE *pf = fopen(str, “r, ccs=UTF-8“);
In Visual C++ 2005, fopen supports Unicode file streams. A flag specifying the desired encoding may be passed to fopen when opening a new file or overwriting an existing file, like this: fopen(“newfile.txt”, “rw, ccs=<encoding>”); Allowed values of the encoding include UNICODE, UTF-8, and UTF16-LE. If the file is already in existence and is opened for reading or appending, the Byte Order Mark (BOM) is used to determine the correct encoding. It is not necessary to specify the encoding with a flag. In fact, the flag will be ignored if it conflicts with the type of the file as indicated by the BOM. The flag is only used when no BOM is present or if the file is a new file. The following table summarizes the modes used in for various flags given to fopen and Byte Order Marks used in the file. Flag UNICODE UTF-8 UTF-16LE If mode is “a, ccs=<encoding>”, fopen will first try to open the file with both read and write access. If it succeeds, it will read the BOM to determine the encoding for this file; however, if it fails, it will use the default encoding for the file. In either case, fopen will then re-open the file with write-only access. (This applies to mode a only, not a+.) |