hickttye 发表于 2019-6-1 23:45:16

fputs的wen't

#include <stdio.h>
#define STLEN 14
int main(void)
{
        char words;

        puts("Enter a string,please.");
        fgets(words, STLEN, stdin);
        printf("Your string twice (puts(), then fputs()):\n");
        puts(words);
        fputs(words, stdout);
        puts("Enter another string,please.");
        fgets(words, STLEN, stdin);
        printf("Your string twice (puts(), then fputs()):\n");
        puts(words);
        fputs(words, stdout);
       
      puts("Done.");

        getchar();
        return 0;
}
为什么第一个fputs打印完后,下一个打印会换行,
而第二个fputs打印完之后,打印“Done”就不会换行?

ba21 发表于 2019-6-2 00:14:05

不知道你想说什么,我看没区别

xypmyp 发表于 2019-6-2 06:15:22

Notice that fputs not only differs from puts in that the destination stream can be specified, but also fputs does not write additional characters, while puts appends a newline character at the end automatically.

hickttye 发表于 2019-6-2 10:55:21

ba21 发表于 2019-6-2 00:14
不知道你想说什么,我看没区别

第二个fputs书上是连接着Done的

hickttye 发表于 2019-6-2 10:57:27

xypmyp 发表于 2019-6-2 06:15
Notice that fputs not only differs from puts in that the destination stream can be specified, but al ...

but the frist fputs appends a newline

hickttye 发表于 2019-6-2 11:01:50

xypmyp 发表于 2019-6-2 06:15
Notice that fputs not only differs from puts in that the destination stream can be specified, but al ...

I understand
页: [1]
查看完整版本: fputs的wen't