相关疑难解决方法(0)

为什么"while(!feof(file))"总是错的?

我看到人们最近在很多帖子中试图读取这样的文件.

#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
    char *path = argc > 1 ? argv[1] : "input.txt";

    FILE *fp = fopen(path, "r");
    if( fp == NULL ) {
        perror(path);
        return EXIT_FAILURE;
    }

    while( !feof(fp) ) {  /* THIS IS WRONG */
        /* Read and process data from file… */
    }
    if( fclose(fp) == 0 ) {
        return EXIT_SUCCESS;
    } else {
        perror(path);
        return EXIT_FAILURE;
    }
}
Run Code Online (Sandbox Code Playgroud)

这个__CODE__循环有什么问题?

c file while-loop feof

550
推荐指数
4
解决办法
21万
查看次数

如何在Windows命令行中使用unicode字符?

我们在Team Foundation Server(TFS)中有一个项目,其中包含非英语字符(š).当我试图编写一些与构建相关的东西时,我们偶然发现了一个问题 - 我们无法将š字母传递给命令行工具.命令提示符或其他什么不是搞砸了,并且tf.exe实用程序找不到指定的项目.

我已经尝试了.bat文件的不同格式(ANSI,带有和不带BOM的 UTF-8 )以及用JavaScript编写脚本(这本身就是Unicode) - 但没有运气.如何执行程序并将其传递给Unicode命令行?

unicode command-line input windows-console

299
推荐指数
12
解决办法
40万
查看次数

标签 统计

c ×1

command-line ×1

feof ×1

file ×1

input ×1

unicode ×1

while-loop ×1

windows-console ×1