在以下代码中:
...
char *message = "This is the message!";
...
printf("Writing to file descriptor FD[%i] \n", fd[1]);
write( fd[1], message, strlen(message));
printf("Reading from file descriptor FD[%i] \n", fd[0]);
read( fd[0], buffer, strlen(message));
printf("Message from FD[%i] : \"%s\" .\n", fd[0], buffer);
我得到以下输出:
"This is the message!���" .
但是如果我删除“!” 从我的消息中,输出没有随机字符...知道为什么我会出现这 3 个随机字符吗?