Scanf()需要输入两次数据。为什么?

时间:2018-04-02 16:14:39

标签: c scanf

char username[50];

char exit_call[50] = "exit";
printf("[Enter Command]:");

scanf("%s", username);


if (strcmp(exit_call, username) == 0) {
    exit(0);
}

write(sock_fd, username, 50);

char buf[BUF_SIZE + 1];

//Initialize the file descriptor set fdset
fd_set read_fds;
// Then have zero bits for all file descriptors
FD_ZERO(&read_fds);

我不明白为什么我必须按enter两次才能让我的程序读取输入。我正在尝试输入"你好"。

编辑:添加额外代码

0 个答案:

没有答案
相关问题