Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C虽然循环在EOF停止,但打印结果是新的一行_C - Fatal编程技术网

C虽然循环在EOF停止,但打印结果是新的一行

C虽然循环在EOF停止,但打印结果是新的一行,c,C,我有以下代码: #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char vector[5][100]; int i = 0; int aux = 0; while (i <5 &am

我有以下代码:

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

        int main()
        {
            char vector[5][100];
            int i = 0;
            int aux = 0;
            while (i <5 && scanf("%s", vector[i])!=EOF)
            {
                i++;
                aux+= 1;
            }

            for (i=0;i<aux;i++)
            {
                printf("%s\n", vector[i]);
            }
            return 0;
        }
想知道我能不能按CTRL-D打印它,第一次输出在新行? 大概是这样的:

 a b c d e f g h i j
 a
 b
 c
 d
 e
第二个问题:

如果我输入
ab c
为什么我必须按多次CTRL-D才能打印输出

问候,

法沃拉斯

printf("\n%s", vector[i]);

这很简单。谢谢那么我的第二个问题呢?@Favolas:对不起,我错过了第二部分。但是约翰成功了。干杯
printf("\n%s", vector[i]);